/* Reset and base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

/* CSS variables */
:root {
  --footer-height: 20px; /* ~20px footer height as requested */
  --color-background: #1a2332;
  --color-surface: #2c3e50;
  --color-surface-muted: #34495e;
  --color-accent: #3498db;
  --color-accent-dark: #2980b9;
  --color-text-primary: #ffffff;
  --color-text-secondary: #8b9dc3;
  --color-border: rgba(255, 255, 255, 0.1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--color-background);
  color: var(--color-text-primary);
  overflow: hidden;
  position: fixed;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

.brand__icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

[data-home-trigger] {
  cursor: pointer;
}

.brand--mobile .brand__icon {
  width: 24px;
  height: 24px;
}

.brand--desktop {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 12px;
  row-gap: 4px;
  align-items: center;
}

.brand--desktop .brand__icon {
  grid-column: 1 / 2;
  grid-row: 1 / 2;
}

.brand--desktop .title {
  grid-column: 2 / 3;
  grid-row: 1 / 2;
  margin-bottom: 0;
}

.brand--desktop .subtitle {
  grid-column: 1 / 3;
  grid-row: 2 / 3;
}

.brand__name {
  font-size: 20px;
  font-weight: 600;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: rgba(26, 35, 50, 0.85);
  border: 1px solid rgba(226, 226, 226, 0.4);
  border-radius: 8px;
  color: inherit;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease;
  backdrop-filter: blur(10px);
}

.icon-button:hover {
  transform: translateY(-1px);
  background: rgba(26, 35, 50, 1);
}

.icon-button:active {
  transform: scale(0.97);
}

.icon-button__icon {
  width: 20px;
  height: 20px;
}

.mobile-header__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Common elements */
.title {
  font-size: 28px;
  font-weight: 600;
  color: #ffffff;
  margin-bottom: 8px;
}

.version {
  font-size: 14px;
  font-weight: 500;
  color: #bdc3c7;
  margin-left: 6px;
  letter-spacing: 0.5px;
}

.subtitle {
  font-size: 14px;
  color: var(--color-text-secondary);
  line-height: 1.4;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.desktop-share-btn {
  margin-left: 0;
}

.level-badge {
  background: linear-gradient(135deg, #27ae60, #229954);
  color: white;
  padding: 4px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: bold;
}

.info-label {
  font-size: 14px;
  color: #bdc3c7;
  min-width: 60px;
}

.info-value {
  font-family: 'SF Mono', 'Monaco', 'Courier New', monospace;
  font-size: 14px;
  color: #ecf0f1;
  font-weight: 600;
  word-break: break-all;
}

/* Location Information (desktop sidebar) — with separators */
.info-display {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.info-display--spaced {
  gap: 12px;
}

.info-display--center {
  align-items: center;
  justify-content: center;
}

.info-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
}

.info-item:last-child {
  border-bottom: none;
}

.info-item--split {
  justify-content: space-between;
  align-items: center;
}

.info-item--column {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

.info-item--wrap {
  flex-wrap: wrap;
  gap: 12px;
}

.toggle-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
}

.level-selector {
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-label {
  font-weight: 600;
  font-size: 13px;
  color: #ecf0f1;
}

.form-input,
.form-select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: #1f2b3c;
  color: #ecf0f1;
  font-size: 13px;
}

.form-select {
  width: auto;
  padding: 8px 10px;
}

.form-input:focus,
.form-select:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.nav-button--compact {
  flex-shrink: 0;
  padding: 10px 16px;
  font-size: 13px;
}

.mobile-menu-toggle__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

/* Mobile info bar rows — add separators for readability */
.mobile-info-bar .info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0; /* add vertical spacing */
  border-bottom: 1px solid rgba(255, 255, 255, 0.1); /* divider line */
  margin-bottom: 0; /* override older margin spacing */
}

.mobile-info-bar .info-row:last-child {
  border-bottom: none;
}

/* Buttons and selectors */
.nav-button {
  background: linear-gradient(135deg, var(--color-accent), var(--color-accent-dark));
  border: none;
  color: white;
  padding: 14px 16px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 500;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
}

.nav-button:hover {
  background: linear-gradient(135deg, #2980b9, #21618c);
  transform: translateY(-1px);
}

.nav-button:active {
  transform: scale(0.98);
}

.nav-button:disabled {
  background: linear-gradient(135deg, #7f8c8d, #95a5a6);
  cursor: not-allowed;
  transform: none;
}

/* Language selector using same background as the page */
.language-selector {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  padding: 14px 16px;
  padding-right: 40px;
  border: none;
  border-radius: 10px;
  color: #ffffff;
  background-color: var(--color-background); /* match body background */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='white' d='M6 9L1.5 4.5h9z'/%3E%3C/svg%3E");
  background-position: right 15px center;
  background-repeat: no-repeat;
  background-size: 12px;
}

.language-selector:hover {
  background-color: var(--color-background);
}

/* Format selector (Numbers/Words toggle) */
.format-selector {
  display: flex;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
  padding: 4px;
  gap: 4px;
}

.format-option {
  flex: 1;
  padding: 12px 16px;
  background: transparent;
  border: none;
  color: #bdc3c7;
  font-size: 14px;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
  min-height: 44px;
}

.format-option:hover {
  color: #ecf0f1;
  background: rgba(255, 255, 255, 0.1);
}

.format-option.active {
  background: linear-gradient(135deg, #3498db, #2980b9);
  color: white;
  box-shadow: 0 2px 8px rgba(52, 152, 219, 0.3);
}

/* Leaflet container */
#map {
  width: 100%;
  height: 100%;
  border-radius: 12px;
  background-color: var(--color-surface-muted);
}

/* Grid cell styles */
.grid-cell {
  fill: transparent;
  stroke: #8b4402; /* brown */
  stroke-width: 1; /* 1px */
  cursor: pointer;
  opacity: 0.7;
}

.grid-cell:hover {
  fill: rgba(139, 68, 2, 0.582); /* brown hover */
  stroke-width: 4; /* highlight on hover */
}

.grid-cell.selected {
  fill: rgba(142, 68, 173, 0.5); 
  stroke: #8e44ad;
  stroke-width: 1; /* keep 1px */
}

/* Toggle to hide grid lines */
.hide-grid-lines .grid-cell {
  stroke-width: 0 !important;
}

/* Even when hidden, show hover highlight at 2px */
.hide-grid-lines .grid-cell:hover {
  stroke-width: 2 !important;
}

/* Custom zoom control with GPS */
.leaflet-control-gps {
  display: block;
  width: 26px;
  height: 26px;
  line-height: 26px;
  text-align: center;
  text-decoration: none;
  color: #333;
  background-color: #fff;
  font-size: 16px;
  margin-bottom: 5px;
  border-radius: 4px;
}

.leaflet-control-gps:hover {
  background-color: #f4f4f4;
}

/* Make zoom controls more rounded */
.leaflet-bar a {
  border-radius: 5px !important;
}

/* Remove borders on touch devices */
.leaflet-touch .leaflet-control-layers, .leaflet-touch .leaflet-bar {
  border: 0px;
}

.selected-marker {
  background: #3498db;
  color: white;
  border-radius: 50%;
  border: 2px solid white;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

/* Mobile close button hidden by default (desktop) */
.mobile-close {
  display: none;
}

/* iOS-style switch */
.ios-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 28px;
}

.ios-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.ios-switch .slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #7f8c8d;
  transition: background 0.2s ease, box-shadow 0.2s ease;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.15);
}

.ios-switch .slider:before {
  position: absolute;
  content: "";
  height: 24px;
  width: 24px;
  left: 2px;
  top: 2px;
  background-color: #fff;
  transition: transform 0.2s ease;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

.ios-switch input:checked + .slider {
  background: #34c759; /* iOS green */
}

.ios-switch input:checked + .slider:before {
  transform: translateX(20px);
}
