:root {
  --bg: #0b0d10;
  --panel: #12151a;
  --panel-hover: #161a20;
  --border: #252a32;
  --text: #f3f4f6;
  --muted: #9299a6;
  --accent: #e6b84a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family:
    Inter,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  background: var(--bg);
  color: var(--text);
}

button,
a {
  font: inherit;
}

.topbar {
  height: 70px;
  padding: 0 32px;
  border-bottom: 1px solid var(--border);

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

.brand {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 2px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 18px;
}

.language-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.language-button:hover {
  color: var(--text);
}

.back-link {
  color: var(--muted);
  text-decoration: none;
}

.back-link:hover {
  color: var(--text);
}

main {
  width: min(1100px, calc(100% - 32px));
  margin: 0 auto;
  padding: 60px 0;
}

.eyebrow {
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 2px;
}

h1 {
  margin: 10px 0;
  font-size: clamp(36px, 7vw, 64px);
}

.subtitle {
  max-width: 650px;
  color: var(--muted);
  line-height: 1.6;
}

.grid {
  display: grid;
  grid-template-columns:
    repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
  margin-top: 45px;
}

.card {
  display: block;
  min-height: 190px;
  padding: 24px;

  border: 1px solid var(--border);
  border-radius: 12px;

  background: var(--panel);
  color: var(--text);
  text-decoration: none;
}

.card h2 {
  margin-top: 0;
}

.card p {
  color: var(--muted);
  line-height: 1.5;
}

.card.active {
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    background 0.15s ease,
    transform 0.15s ease;
}

.card.active:hover {
  border-color: var(--accent);
  background: var(--panel-hover);
  transform: translateY(-2px);
}

.status {
  display: inline-block;
  margin-top: 14px;

  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

@media (max-width: 700px) {
  .topbar {
    padding: 0 18px;
  }

  .topbar-right {
    gap: 12px;
  }

  main {
    padding-top: 35px;
  }
}


/* MEASURE DISTANCE */

.measure-layout {
  width: 100%;
  padding: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  height: calc(100vh - 70px);
}

.map-panel {
  min-width: 0;
  background: #080a0d;
}

.map-placeholder {
  width: 100%;
  height: 100%;
  min-height: 500px;

  display: flex;
  align-items: center;
  justify-content: center;

  background:
    linear-gradient(
      135deg,
      #11151a,
      #080a0d
    );

  color: var(--muted);
}

.map-placeholder > div {
  display: flex;
  flex-direction: column;
  text-align: center;
  gap: 8px;
}

.map-placeholder strong {
  color: var(--text);
  font-size: 22px;
}

.control-panel {
  overflow-y: auto;
  padding: 28px;

  border-left: 1px solid var(--border);
  background: var(--bg);
}

.panel-heading h1 {
  margin: 8px 0;
  font-size: 32px;
}

.panel-heading p {
  color: var(--muted);
  line-height: 1.5;
}

.info-card,
.distance-card {
  margin-top: 16px;
  padding: 18px;

  border: 1px solid var(--border);
  border-radius: 10px;

  background: var(--panel);

  display: flex;
  flex-direction: column;
  gap: 7px;
}

.info-label,
.distance-card span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.5px;
}

.info-secondary {
  color: var(--muted);
  font-size: 13px;
}

.distance-card strong {
  font-size: 34px;
}

.actions {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.primary-button,
.secondary-button {
  min-height: 46px;
  padding: 0 16px;

  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
}

.primary-button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #111;
}

.secondary-button {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
}

.secondary-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.saved-section {
  margin-top: 32px;
}

.saved-section h2 {
  font-size: 18px;
}

.empty-state {
  padding: 18px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
}

@media (max-width: 850px) {

  .measure-layout {
    display: flex;
    flex-direction: column;
    height: auto;
  }

  .map-panel {
    height: 55vh;
    min-height: 390px;
  }

  .map-placeholder {
    min-height: 100%;
  }

  .control-panel {
    border-left: 0;
    border-top: 1px solid var(--border);
    padding: 22px 18px 40px;
  }

  .brand {
    font-size: 14px;
  }
}


/* LIVE MAP */

.map {
  width: 100%;
  height: 100%;
  min-height: 500px;
  background: #080a0d;
}

#setTargetButton.target-mode {
  border-color: var(--accent);
  color: var(--accent);
}

.leaflet-container {
  font-family:
    Inter,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

@media (max-width: 850px) {
  .map {
    min-height: 100%;
  }
}


/* =========================================================
   SAVED MEASUREMENTS
   ========================================================= */

.saved-measurements-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.saved-measurement-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;

  padding: 16px;

  background: #101419;
  border: 1px solid #29313a;
  border-radius: 12px;
}

.saved-measurement-info {
  min-width: 0;

  display: flex;
  flex-direction: column;
  gap: 4px;
}

.saved-measurement-info strong {
  color: #ffffff;
  font-size: 15px;
  line-height: 1.3;

  overflow-wrap: anywhere;
}

.saved-measurement-info span {
  color: #f4c247;
  font-size: 14px;
  font-weight: 700;
}

.saved-measurement-info small {
  color: #91a0b3;
  font-size: 12px;
}

.saved-measurement-actions {
  display: flex;
  flex-shrink: 0;
  gap: 8px;
}

.saved-measurement-actions button {
  min-height: 38px;
  padding: 0 13px;

  border: 1px solid #303944;
  border-radius: 8px;

  background: #12171d;
  color: #ffffff;

  font: inherit;
  font-size: 13px;
  font-weight: 700;

  cursor: pointer;
}

.saved-measurement-actions button:hover {
  border-color: #f4c247;
}

.saved-delete-button {
  color: #ff6b6b !important;
}

.saved-delete-button:hover {
  border-color: #ff6b6b !important;
}


/* Mobile */

@media (max-width: 600px) {

  .saved-measurement-card {
    align-items: stretch;
    flex-direction: column;
  }

  .saved-measurement-actions {
    width: 100%;
  }

  .saved-measurement-actions button {
    flex: 1;
  }

}


/* =========================================================
   SHOOTER / TARGET MAP MARKERS
   ========================================================= */

.shooting-map-marker-wrapper {
  background: transparent !important;
  border: 0 !important;
}

.shooting-map-marker {
  position: relative;

  width: 18px;
  height: 18px;

  display: flex;
  align-items: center;
  justify-content: center;
}

.shooting-marker-dot {
  position: relative;
  z-index: 2;

  width: 14px;
  height: 14px;

  border: 3px solid #ffffff;
  border-radius: 50%;

  box-shadow:
    0 0 0 2px rgba(0, 0, 0, 0.7),
    0 2px 8px rgba(0, 0, 0, 0.8);
}


/* SHOOTER */

.shooter-marker .shooting-marker-dot {
  background: #f4a62a;
}

.shooter-marker .shooting-marker-label {
  color: #ffc04a;
}


/* TARGET */

.target-marker .shooting-marker-dot {
  background: #2388ff;
}

.target-marker .shooting-marker-label {
  color: #58a8ff;
}


/* LABEL */

.shooting-marker-label {
  position: absolute;

  left: 23px;
  top: 50%;

  transform: translateY(-50%);

  z-index: 1;

  white-space: nowrap;

  padding: 5px 8px;

  background: rgba(8, 10, 13, 0.90);

  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;

  font-size: 10px;
  font-weight: 800;
  line-height: 1;

  letter-spacing: 0.7px;

  text-shadow:
    0 1px 2px rgba(0, 0, 0, 0.9);

  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.45);

  pointer-events: none;
}


/* Keep labels visible above satellite imagery */

.leaflet-marker-pane {
  z-index: 600;
}



/* =========================================================
   SHOOTING NAV + CLEAR POSITION V5
   ========================================================= */

.back-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 6px 7px;

  border: 1px solid transparent;
  border-radius: 9px;

  color: var(--muted) !important;
  text-decoration: none !important;

  font-size: 13px;
  font-weight: 750;
  line-height: 1;

  transition:
    color 0.15s ease,
    border-color 0.15s ease,
    background 0.15s ease,
    transform 0.15s ease;
}

.back-button::before {
  content: "←";

  width: 27px;
  height: 27px;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  border: 1px solid rgba(230, 184, 74, 0.28);
  border-radius: 50%;

  background: rgba(230, 184, 74, 0.08);
  color: var(--accent);

  font-size: 16px;
  font-weight: 900;
}

.back-button:hover {
  color: var(--text) !important;
  border-color: var(--border);
  background: rgba(255, 255, 255, 0.025);
  transform: translateX(-1px);
}

.clear-position-button {
  min-height: 46px;
  width: 100%;

  border: 1px solid rgba(239, 111, 111, 0.34);
  border-radius: 8px;

  background: rgba(239, 111, 111, 0.045);
  color: #d9a0a0;

  cursor: pointer;
  font-weight: 750;

  transition:
    border-color 0.15s ease,
    background 0.15s ease,
    color 0.15s ease;
}

.clear-position-button::before {
  content: "×";
  margin-right: 8px;
  font-size: 17px;
  line-height: 1;
}

.clear-position-button:hover:not(:disabled) {
  border-color: rgba(239, 111, 111, 0.7);
  background: rgba(239, 111, 111, 0.09);
  color: #f0b1b1;
}

.clear-position-button:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}


/* =========================================================
   MEASURE RINGS + CLEAR TARGET V6
   ========================================================= */

.clear-target-button {
  min-height: 46px;
  width: 100%;

  border: 1px solid rgba(88, 168, 255, 0.34);
  border-radius: 8px;

  background: rgba(88, 168, 255, 0.04);
  color: #9acbff;

  cursor: pointer;
  font-weight: 750;
}

.clear-target-button::before {
  content: "×";
  margin-right: 8px;
  font-size: 17px;
  line-height: 1;
}

.clear-target-button:hover:not(:disabled) {
  border-color: rgba(88, 168, 255, 0.72);
  background: rgba(88, 168, 255, 0.085);
}

.clear-target-button:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.distance-rings-panel {
  margin-top: 20px;
  padding: 16px;

  border: 1px solid var(--border);
  border-radius: 10px;

  background: rgba(255, 255, 255, 0.018);
}

.distance-rings-hint {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.distance-rings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.distance-ring-field > span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.1px;
}

.distance-ring-field select {
  width: 100%;
  min-height: 42px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
}

.distance-rings-toggle {
  width: 100%;
  margin-top: 10px;
}

.distance-rings-toggle.active {
  border-color: rgba(230, 184, 74, 0.66);
  color: var(--accent);
  background: rgba(230, 184, 74, 0.06);
}

.measure-distance-ring {
  stroke: rgba(230, 184, 74, 0.62);
  fill: transparent;
}

.measure-distance-ring.outer {
  stroke: rgba(230, 184, 74, 0.95);
}

.measure-ring-label-wrapper {
  background: transparent !important;
  border: 0 !important;
  pointer-events: none !important;
}

.measure-ring-label {
  width: max-content;
  min-width: 48px;
  padding: 3px 6px;
  border: 1px solid rgba(230, 184, 74, 0.30);
  border-radius: 5px;
  background: rgba(8, 10, 13, 0.84);
  color: #e7d69d;
  font-size: 9px;
  font-weight: 800;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  transform: translateX(-50%);
}

.measure-ring-label.outer {
  border-color: rgba(230, 184, 74, 0.72);
  color: #ffd772;
}

@media (max-width: 620px) {
  .distance-rings-grid {
    grid-template-columns: 1fr;
  }
}
