* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0b1e2d;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-user-select: none;
  user-select: none;
}

#map {
  position: absolute;
  inset: 0;
}

/* HUD */
#hud {
  position: absolute;
  top: env(safe-area-inset-top, 0px);
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 10px 10px 0;
  pointer-events: none;
  z-index: 5;
}

.hud-item {
  background: rgba(11, 30, 45, 0.82);
  color: #e8f4f8;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 6px 12px;
  min-width: 84px;
  text-align: center;
  backdrop-filter: blur(6px);
}

.hud-label {
  display: block;
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #7fa8bd;
}

.hud-value {
  display: inline-block;
  font-size: 20px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.hud-unit {
  font-size: 11px;
  color: #7fa8bd;
  margin-left: 2px;
}

/* Follow button */
#follow-btn {
  position: absolute;
  right: 16px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 24px);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(11, 30, 45, 0.9);
  color: #7fa8bd;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

#follow-btn.active {
  background: #1a7fa0;
  color: #ffffff;
  border-color: #1a7fa0;
}

/* Waypoint button (empilé au-dessus du bouton suivre) */
#waypoint-btn {
  position: absolute;
  right: 16px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 88px);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(11, 30, 45, 0.9);
  color: #7fa8bd;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

#waypoint-btn.active {
  background: #1a7fa0;
  color: #ffffff;
  border-color: #1a7fa0;
}

/* Waypoint panel */
#waypoint-panel {
  position: absolute;
  right: 16px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 148px);
  width: 250px;
  max-height: 70vh;
  overflow-y: auto;
  background: rgba(11, 30, 45, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 12px;
  z-index: 7;
  color: #e8f4f8;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  -webkit-user-select: auto;
  user-select: auto;
}

#waypoint-panel.hidden {
  display: none;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  margin-bottom: 10px;
}

.panel-header button {
  background: none;
  border: none;
  color: #7fa8bd;
  font-size: 20px;
  line-height: 1;
  padding: 0 4px;
}

#waypoint-here-btn {
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.06);
  color: #e8f4f8;
  font-size: 13px;
  margin-bottom: 10px;
}

.panel-divider {
  text-align: center;
  font-size: 11px;
  color: #7fa8bd;
  margin: 10px 0;
}

.format-toggle {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.format-btn {
  flex: 1;
  padding: 6px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: transparent;
  color: #7fa8bd;
  font-size: 12px;
}

.format-btn.active {
  background: #1a7fa0;
  color: #ffffff;
  border-color: #1a7fa0;
}

.coord-group.hidden {
  display: none;
}

.coord-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 12px;
}

.coord-row span {
  width: 26px;
  color: #7fa8bd;
}

.coord-row input {
  flex: 1;
  min-width: 0;
}

.dms-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 8px;
  font-size: 12px;
}

.dms-row span {
  width: 22px;
  color: #7fa8bd;
}

.dms-row input {
  width: 44px;
  min-width: 0;
}

#waypoint-panel input,
#waypoint-panel select {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  color: #e8f4f8;
  padding: 5px 6px;
  font-size: 12px;
}

#waypoint-name {
  width: 100%;
  margin-bottom: 10px;
}

#waypoint-add-btn {
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  border: none;
  background: #1a7fa0;
  color: #ffffff;
  font-weight: 600;
  font-size: 13px;
}

/* Waypoint marker popup */
.waypoint-popup .maplibregl-popup-content {
  background: rgba(11, 30, 45, 0.95);
  color: #e8f4f8;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
}

.waypoint-popup .maplibregl-popup-tip {
  border-top-color: rgba(11, 30, 45, 0.95);
  border-bottom-color: rgba(11, 30, 45, 0.95);
}

.waypoint-popup-delete {
  margin-top: 8px;
  width: 100%;
  padding: 6px;
  border-radius: 6px;
  border: none;
  background: #b3352a;
  color: #fff;
  font-size: 12px;
}

/* Status / error banner */
#status {
  position: absolute;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 24px);
  left: 16px;
  right: 84px;
  background: rgba(120, 30, 20, 0.9);
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  z-index: 6;
}

#status.hidden {
  display: none;
}

/* Boat marker */
.boat-marker {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  will-change: transform;
}

.boat-marker svg {
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.6));
}

.maplibregl-ctrl-attrib {
  font-size: 10px;
}
