* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: system-ui, -apple-system, sans-serif;
  background: #1a2b1e;
  color: #e8eee9;
}

body { display: flex; flex-direction: column; }

/* ---------- top bar ---------- */
#topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: #14231a;
  border-bottom: 1px solid #2c4433;
  flex: 0 0 auto;
}

#session-select {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 16px;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid #3a5a45;
  background: #1f3527;
  color: #e8eee9;
}

#add-session, #del-session, #heatmap-toggle {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  font-size: 20px;
  border-radius: 8px;
  border: 1px solid #3a5a45;
  background: #1f3527;
  color: #e8eee9;
}

#heatmap-toggle.active {
  background: #4c8c5f;
  border-color: #4c8c5f;
  color: white;
}

#progress { font-size: 14px; color: #9db8a5; white-space: nowrap; }

#net-status {
  font-size: 12px;
  color: #ffb4a2;
  border: 1px solid #ffb4a2;
  border-radius: 6px;
  padding: 2px 6px;
}

/* ---------- map ---------- */
#map-wrap { flex: 1 1 auto; min-height: 0; position: relative; }

#legend {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  background: rgba(20, 35, 26, 0.9);
  border-top: 1px solid #2c4433;
  padding: 4px 6px calc(4px + env(safe-area-inset-bottom));
  z-index: 5;
  pointer-events: none;
}

.legend-cell {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 0;
}

.legend-swatch {
  display: block;
  width: 100%;
  height: 12px;
  border: 1px solid #2c4433;
}

.legend-value {
  font-size: 9px;
  color: #9db8a5;
  white-space: nowrap;
}

#map {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  background: #24382a;
}

.scene-border { stroke: #6f8a76; stroke-width: 0.08; }
.tpa-line { stroke: #6f8a76; stroke-width: 0.06; stroke-dasharray: 0.5 0.35; }
.court-line { stroke: #c8874f; stroke-width: 0.08; fill: none; }
.court-line.net { stroke-width: 0.12; }

.spot .spot-dot {
  fill: #1a2b1e;
  stroke: #9db8a5;
  stroke-width: 0.09;
}
.spot.custom .spot-dot { stroke-dasharray: 0.2 0.15; }
.spot .spot-chip {
  fill: #4c8c5f;
  stroke: transparent;
  stroke-width: 0.08;
}
.spot.custom .spot-chip { stroke: #a5d6b0; stroke-dasharray: 0.15 0.12; }
.spot text {
  pointer-events: none;
  font-family: system-ui, sans-serif;
  text-anchor: middle;
  dominant-baseline: central;
}
.spot .spot-value {
  fill: #e8eee9;
  font-size: 0.62px;
  font-weight: 600;
}
.spot .spot-label {
  font-size: 0.45px;
  fill: #9db8a5;
}

/* ---------- overlays ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: #1a2b1e;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
}

.pin-box { text-align: center; display: flex; flex-direction: column; gap: 12px; width: 220px; }
.pin-box h1 { font-size: 22px; }
.pin-box p { color: #9db8a5; font-size: 14px; }
.pin-box input {
  font-size: 24px;
  text-align: center;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid #3a5a45;
  background: #1f3527;
  color: #e8eee9;
}
.pin-box button {
  font-size: 17px;
  padding: 10px;
  border-radius: 10px;
  border: none;
  background: #4c8c5f;
  color: white;
}

/* ---------- bottom sheet ---------- */
#sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 10;
}

#sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: #1f3527;
  border-top: 1px solid #3a5a45;
  border-radius: 16px 16px 0 0;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sheet-head { display: flex; justify-content: space-between; align-items: baseline; }
.sheet-head strong { font-size: 18px; }
#sheet-ref { font-size: 13px; color: #9db8a5; }

#lux-input {
  font-size: 32px;
  text-align: center;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid #3a5a45;
  background: #14231a;
  color: #e8eee9;
  width: 100%;
}

.sheet-actions { display: flex; gap: 10px; }
.sheet-actions button {
  flex: 1;
  font-size: 17px;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid #3a5a45;
  background: #1f3527;
  color: #e8eee9;
}
.sheet-actions button.primary { background: #4c8c5f; border-color: #4c8c5f; color: white; }
.sheet-actions button.danger { background: #4a2320; border-color: #7a3a34; color: #ffb4a2; flex: 0 0 auto; padding: 12px 16px; }
.sheet-actions button:disabled { opacity: 0.5; }

.error { color: #ffb4a2; font-size: 14px; }

/* ---------- toast ---------- */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #14231a;
  border: 1px solid #3a5a45;
  color: #e8eee9;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 40;
  max-width: 90vw;
}

.hidden { display: none !important; }
