:root {
  --bg: #222;
  --container-bg: #333;
  --text: #eee;
  --accent: #444;
  --accent-hover: #666;
  --border: #444;
  --info-bg: #23272b;
  --info-text: #eee;
  --info-border: #444;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f7f7f7;
    --container-bg: #fff;
    --text: #222;
    --accent: #e0e0e0;
    --accent-hover: #c0c0c0;
    --border: #ccc;
    --info-bg: #f7f7f7;
    --info-text: #222;
    --info-border: #ccc;
  }
}
body {
  font-family: Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}
body.light-mode {
  --bg: #f7f7f7;
  --container-bg: #fff;
  --text: #222;
  --accent: #e0e0e0;
  --accent-hover: #c0c0c0;
  --border: #ccc;
  --info-bg: #f7f7f7;
  --info-text: #222;
  --info-border: #ccc;
}
body.dark-mode {
  --bg: #222;
  --container-bg: #333;
  --text: #eee;
  --accent: #444;
  --accent-hover: #666;
  --border: #444;
  --info-bg: #23272b;
  --info-text: #eee;
  --info-border: #444;
}
.container {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  justify-content: center;
  gap: 16px;
  width: fit-content;
  max-width: 100vw;
  height: auto;
  min-height: 0;
  max-height: 100vh;
  margin: 0 auto;
  background: var(--container-bg);
  padding: 24px;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
  box-sizing: border-box;
  overflow: hidden;
}
.map-side {
  flex: 0 0 auto;
}
h1 {
  text-align: center;
  margin-bottom: 24px;
}
#map-select, #mode-select {
  width: 100%;
  padding: 8px;
  margin-bottom: 16px;
  font-size: 1rem;
  border-radius: 4px;
  border: none;
  background: var(--accent);
  color: var(--text);
  cursor: pointer;
}
#map-container {
  aspect-ratio: 1 / 1;
  width: min(85vh, 70vw);
  height: min(85vh, 70vw);
  position: relative;
  background: #111;
  margin-bottom: 16px;
  border-radius: 8px;
  overflow: hidden;
}
#map-image, #map-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 8px;
}
.controls-side {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 16px;
  min-width: 180px;
  max-width: 320px;
  box-sizing: border-box;
  padding-top: 24px;
}
.controls-side label {
  margin-bottom: 2px;
  display: block;
}
.controls-side select {
  margin-bottom: 8px;
  display: block;
}
#map-info {
  margin-top: 8px;
  margin-bottom: 8px;
  text-align: left;
  font-size: 1rem;
  min-height: 1.2em;
  color: var(--info-text);
}
#result {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 1.2rem;
  min-height: 1.8em;
  background: var(--info-bg);
  color: var(--info-text);
  border: 2px solid var(--info-border);
  border-radius: 8px;
  padding: 12px 0;
  min-width: 160px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.5px;
}
#reset-position, #toggle-helpers {
  padding: 8px 20px;
  font-size: 1rem;
  background: var(--accent);
  color: var(--text);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s;
}
#reset-position {
  background: #d32f2f;
  color: #fff;
  border: none;
  transition: background 0.2s;
}
#reset-position:hover {
  background: #b71c1c;
}
#reset-position[disabled] {
  background: #888 !important;
  color: #eee !important;
  cursor: not-allowed !important;
  opacity: 0.7;
}
#toggle-helpers:hover {
  background: var(--accent-hover);
}
#toggle-helpers[disabled] {
  background: #888 !important;
  color: #eee !important;
  cursor: not-allowed !important;
  opacity: 0.7;
}
.button-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 0;
}
.collapsible-landing {
  width: 100%;
  background: var(--info-bg);
  padding: 0;
  margin-bottom: 0;
}
#toggle-landing {
  width: 100%;
  background: var(--accent);
  color: var(--text);
  border: none;
  font-size: 1.1rem;
  padding: 10px 0;
  cursor: pointer;
  text-align: left;
  transition: background 0.2s;
  padding-left: 10px;
}
#toggle-landing:hover {
  background: var(--accent-hover);
}
#landing-content {
  background: var(--info-bg);
  color: var(--info-text);
  padding: 18px 24px 12px 24px;
  border-bottom: 1px solid var(--info-border);
}
#landing-content h2, #landing-content h3 {
  margin-top: 0;
}
#landing-content ul {
  margin-top: 0;
  margin-bottom: 1em;
}
.theme-toggle {
  display: block;
  margin-top: auto;
  margin-bottom: 20px;
  margin-left: 0;
  margin-right: 0;
  padding: 10px 24px;
  font-size: 1rem;
  background: var(--accent);
  color: var(--text);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s;
}
.theme-toggle:hover {
  background: var(--accent-hover);
}
.collapsible-landing a {
  color: #fff;
  text-decoration: underline;
  cursor: pointer;
}
body.light-mode .collapsible-landing a {
  color: #fff;
}
button, .theme-toggle, #toggle-landing, #reset-position, #toggle-helpers, #close-landing {
  cursor: pointer;
}
#map-canvas:hover {
  cursor: crosshair;
}
@media (max-width: 900px) {
  body {
    overflow-x: hidden;
  }
  .container {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
    padding: 8px;
    padding-left: 8px;
    padding-right: 8px;
  }
  .map-side,
  .controls-side {
    width: 100%;
    box-sizing: border-box;
  }
  .controls-side {
    max-width: 100vw;
    width: 100%;
    flex: 1 1 auto;
  }
  .map-side {
    width: 100%;
  }
  #map-container {
    box-sizing: border-box;
    width: calc(min(100vw, 100vh - 32px) - 16px);
    height: calc(min(100vw, 100vh - 32px) - 16px);
    margin-left: auto;
    margin-right: auto;
    aspect-ratio: 1 / 1;
    max-width: 100vw;
    max-height: calc(100vh - 32px);
    border: none;
  }
  #landing-content img {
    width: 100%;
    max-width: 100%;
    margin-left: 10px;
    margin-right: 10px;
    height: auto;
    display: block;
  }
}
.container-title {
  width: 100%;
  text-align: center;
  margin-top: 24px;
  margin-bottom: 0.5em;
}
.distance-label {
  margin-top: 18px;
  margin-bottom: 2px;
  font-size: 1.05rem;
  color: var(--info-text);
  text-align: left;
  display: block;
}  