* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: #111;
  color: #fff;
}

#map {
  position: fixed;
  inset: 0;
  height: 100dvh;
  width: 100vw;
  background: #222;
}

.hidden { display: none !important; }

.overlay {
  position: fixed;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  border-radius: 10px;
  backdrop-filter: blur(4px);
}

/* Compass: top right */
#compass {
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  right: calc(env(safe-area-inset-right, 0px) + 10px);
  width: 92px;
  padding: 6px 0 4px;
  text-align: center;
}

#compass-dial {
  position: relative;
  width: 76px;
  height: 76px;
  margin: 0 auto;
}

/* Fixed dial with north at the top; the arrow turns to the direction you are facing. */
#compass-rose {
  position: absolute;
  inset: 3px;
  border: 2px solid #ddd;
  border-radius: 50%;
}

#compass-arrow {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  transition: transform 0.1s linear;
}

#compass-rose span {
  position: absolute;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}
#compass-rose .rose-n { top: 2px; left: 50%; transform: translateX(-50%); color: #ff5252; }
#compass-rose .rose-s { bottom: 2px; left: 50%; transform: translateX(-50%); }
#compass-rose .rose-e { right: 3px; top: 50%; transform: translateY(-50%); }
#compass-rose .rose-w { left: 3px; top: 50%; transform: translateY(-50%); }

#compass-readout {
  margin-top: 4px;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

/* Location accuracy under the heading readout, separated by a subtle divider */
#accuracy {
  width: 64px;
  margin: 5px auto 0;
  padding-top: 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.22);
  font-size: 13px;
  color: #9ad0ff;
  font-variant-numeric: tabular-nums;
}
#accuracy.poor { color: #ffb74d; }

/* Recenter: bottom right */
#recenter {
  bottom: calc(env(safe-area-inset-bottom, 0px) + 22px);
  right: calc(env(safe-area-inset-right, 0px) + 10px);
  width: 44px;
  height: 44px;
  font-size: 24px;
  border: 0;
  padding: 0;
}

/* Start / permission screen */
.screen {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: #111;
}
.card { max-width: 420px; text-align: center; }
.card h1 { margin: 0 0 12px; }
/* Start screen: the logo as the heading */
.card h1 .start-logo { display: block; width: min(340px, 80vw); height: auto; margin: 0 auto 6px; }
.card p { line-height: 1.4; color: #ccc; }
.card button {
  margin-top: 12px;
  padding: 14px 28px;
  font-size: 18px;
  border: 0;
  border-radius: 10px;
  background: #1e88e5;
  color: #fff;
}
.message { color: #ffb74d !important; min-height: 1.4em; }

/* User location marker */
.user-marker { position: relative; }
/* Planning mode (desktop): the dot can be dragged */
.user-marker.plan { cursor: grab; }
.user-marker.plan:active { cursor: grabbing; }
/* Place search (desktop planning): top centre, between the menu and the compass */
#search {
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 1500;
  width: min(440px, calc(100vw - 230px));
  display: flex;
  gap: 6px;
  padding: 5px;
}
#search input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  font-size: 15px;
  color: #fff;
  background: #2c2c2e;
  border: 1px solid #555;
  border-radius: 8px;
}
#search input:focus { outline: 2px solid #1e88e5; border-color: #1e88e5; }
#search > button {
  flex: 0 0 40px;
  border: 0;
  border-radius: 8px;
  background: #1e88e5;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
}
#search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: rgba(28, 28, 30, 0.96);
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
  max-height: 50vh;
  overflow-y: auto;
}
#search-results button {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: #ddd;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
#search-results button:hover { background: rgba(255, 255, 255, 0.1); }
#search-results button.current { color: #fff; font-weight: 600; box-shadow: inset 3px 0 0 #1e88e5; }
#search-results .search-message { padding: 8px 10px; color: #bbb; font-size: 13px; }
#search-results .search-credit { padding: 4px 10px 2px; color: #888; font-size: 11px; }
#search-results .search-credit a { color: #9cc9f0; }
.user-dot {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  background: #1e88e5;
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.6);
}
.user-heading {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  display: none;
}
.user-heading::before {
  content: "";
  position: absolute;
  left: -9px;
  top: -34px;
  border-left: 9px solid transparent;
  border-right: 9px solid transparent;
  border-bottom: 18px solid rgba(30, 136, 229, 0.9);
}
.user-heading.on { display: block; }

/* Map credit (js/app.js): a few characters until tapped, then the full text, wrapping clear of the
   recenter button */
.leaflet-control.map-credit {
  max-width: calc(100vw - 90px);
  margin-bottom: 2px;
  padding: 1px 5px;
  border: 0;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.7);
  color: #333;
  font: 12px/1.3 system-ui, sans-serif;
  text-align: left;
  cursor: pointer;
}
.leaflet-bottom { margin-bottom: env(safe-area-inset-bottom, 0px); }
/* Scale bar: no white box; white text and bracket with a dark shadow so it reads on any imagery */
.leaflet-control-scale-line {
  background: none;
  border-color: #fff;
  color: #fff;
  font-weight: 600;
  text-shadow: 0 0 2px #000, 0 0 4px #000;
  filter: drop-shadow(0 0 1px #000);
}

/* Menu: top left */
#menu-btn {
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  left: calc(env(safe-area-inset-left, 0px) + 10px);
  width: 44px;
  height: 44px;
  font-size: 24px;
  border: 0;
  padding: 0;
}
#menu {
  top: calc(env(safe-area-inset-top, 0px) + 60px);
  left: calc(env(safe-area-inset-left, 0px) + 10px);
  z-index: 1500;
  min-width: 170px;
  padding: 4px;
  display: flex;
  flex-direction: column;
}
#menu button {
  background: none;
  border: 0;
  color: #fff;
  text-align: left;
  font-size: 17px;
  padding: 12px 14px;
  border-radius: 8px;
}
#menu button:active { background: rgba(255, 255, 255, 0.18); }
.menu-divider { height: 1px; margin: 4px 10px; background: rgba(255, 255, 255, 0.2); }
/* TEMPORARY: "Load sample" test item, set apart from the real menu items */
#menu button.temp { color: #aaa; font-size: 15px; border-top: 1px solid rgba(255, 255, 255, 0.15); border-radius: 0 0 8px 8px; }

#toast {
  position: fixed;
  z-index: 4000;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 80px);
  transform: translateX(-50%);
  max-width: 90vw;
  padding: 10px 16px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  font-size: 15px;
}

/* Modal dialogs */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: rgba(0, 0, 0, 0.6);
}
.modal-card {
  width: 100%;
  max-width: 560px;
  max-height: 88dvh;
  display: flex;
  flex-direction: column;
  padding: 16px;
  background: #1c1c1e;
  border-radius: 14px;
}
.modal-card h2 { margin: 0 0 12px; font-size: 20px; }
.modal-card > div:not(.modal-actions) { overflow-y: auto; min-height: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }
.modal-card button {
  padding: 10px 18px;
  font-size: 16px;
  border: 0;
  border-radius: 8px;
  background: #3a3a3c;
  color: #fff;
}
.modal-card button.primary { background: #1e88e5; }
.modal-card input, .modal-card select {
  width: 100%;
  padding: 9px 8px;
  font-size: 16px; /* 16px prevents iOS zoom-on-focus */
  border: 1px solid #555;
  border-radius: 6px;
  background: #2c2c2e;
  color: #fff;
}
.field-label { display: block; margin-bottom: 6px; color: #ccc; }

.table-wrap { max-height: 55dvh; overflow-y: auto; }
table.targets { width: 100%; border-collapse: collapse; }
table.targets th {
  position: sticky;
  top: 0;
  background: #1c1c1e;
  padding: 6px 4px;
  font-size: 12px;
  font-weight: 600;
  color: #ccc;
  text-align: left;
}
table.targets td { padding: 4px; }
table.targets td.num { width: 3.2em; text-align: center; font-weight: 700; }
.modal-card button.add-row { margin-top: 10px; width: 100%; }

.saved-list { list-style: none; margin: 0; padding: 0; }
.saved-list li { display: flex; gap: 8px; margin-bottom: 8px; }
.saved-list .name { flex: 1; text-align: left; overflow-wrap: anywhere; }
.saved-list .delete { background: #8e2b2b; }
.empty { color: #aaa; }
.share-note { margin: 0 0 10px; color: #ccc; font-size: 14px; }
.modal-card input.share-url { font-size: 13px; }

table.targets select { padding: 9px 2px; }
table.targets td.num { width: 2.6em; }
table.targets th:nth-child(4), table.targets td:nth-child(4) { width: 32%; }

/* Compass without sensor data yet (desktop, denied, or still starting) */
#compass.inactive #compass-dial, #compass.inactive #compass-readout { opacity: 0.55; }

/* Logo: bottom middle, always visible, never blocks map gestures */
#logo {
  position: fixed;
  z-index: 1000;
  left: 50%;
  bottom: env(safe-area-inset-bottom, 0px);
  transform: translateX(-50%);
  width: clamp(120px, 49vw, 230px);
  height: auto;
  pointer-events: none;
  user-select: none;
}

/* Field dialog */
table.targets.field th:nth-child(4), table.targets.field td:nth-child(4) { width: 44px; }
/* Invalid: dashed, thicker border as well as red, so it doesn't rely on colour alone */
.modal-card input.invalid { border: 2px dashed #ff6b6b; background: #3a2222; }
.modal-card button.here { padding: 8px 0; width: 40px; font-size: 20px; }
.field-summary { margin: 10px 0 4px; font-weight: 600; }
.lane-summary { margin: 8px 0 0; color: #ccc; font-size: 14px; }
.lane-summary.over { color: #ffb74d; font-weight: 600; }
/* Field sheet text: readable sizes (16px inputs also stop iOS zooming in on focus) */
table.targets.field th { font-size: 14px; }
table.targets.field td.label { width: 25%; font-size: 15px; line-height: 1.25; padding-right: 6px; white-space: nowrap; }
table.targets.field input { font-size: 16px; padding: 9px 5px; -moz-appearance: textfield; appearance: textfield; }
table.targets.field input::-webkit-inner-spin-button,
table.targets.field input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
table.targets.field th:nth-child(4), table.targets.field td:nth-child(4) { width: 38px; }
.modal-card button.here { width: 34px; }

/* Version tag: tiny, bottom right, above the start screen so stale caches are easy to spot */
#version {
  position: fixed;
  z-index: 2500;
  right: calc(env(safe-area-inset-right, 0px) + 8px);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 4px);
  font-size: 10px;
  line-height: 1;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 0 3px #000, 0 0 3px #000;
  pointer-events: none;
  user-select: none;
  font-variant-numeric: tabular-nums;
}

/* Target numbering direction */
.segmented { display: flex; border: 1px solid #555; border-radius: 10px; overflow: hidden; }
.modal-card button.seg { flex: 1; border-radius: 0; background: #2c2c2e; font-size: 15px; padding: 10px 6px; }
.modal-card button.seg + button.seg { border-left: 1px solid #555; }
.modal-card button.seg.active { background: #1e88e5; font-weight: 700; }

/* Delete-row button in Targets */
table.targets:not(.field) th:nth-child(5), table.targets:not(.field) td:nth-child(5) { width: 38px; }
.modal-card button.del { width: 34px; padding: 8px 0; font-size: 16px; background: #5a2a2a; }
.modal-card button.del:disabled { opacity: 0.3; }
table.targets input[type=number] { -moz-appearance: textfield; appearance: textfield; }
table.targets input[type=number]::-webkit-inner-spin-button,
table.targets input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
table.targets:not(.field) input { padding: 9px 4px; text-align: center; }
table.targets:not(.field) th:nth-child(4), table.targets:not(.field) td:nth-child(4) { width: 28%; }

/* Bow type column only needs room for R / C */
table.targets:not(.field) th:nth-child(4), table.targets:not(.field) td:nth-child(4) { width: 64px; }

/* Target icons on the map */
.tgt-icon { background: none; border: 0; }
.tgt { position: relative; width: 34px; height: 34px; }
.tgt .face { width: 34px; height: 34px; display: block; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.7)); }
.tgt-num {
  position: absolute;
  top: -6px;
  left: -6px;
  min-width: 16px;
  height: 16px;
  padding: 0 3px;
  border-radius: 8px;
  background: #111;
  border: 1px solid #fff;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 14px;
  text-align: center;
}
.tgt-dist {
  position: absolute;
  top: 35px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 0 3px #000, 0 0 3px #000;
}
.leaflet-popup-content { color: #111; font-size: 13px; }

/* Menu button icon: three arrows */
#menu-btn { color: #fff; }
#menu-btn svg { display: block; width: 28px; height: 28px; margin: auto; }

/* Target picker: bottom centre, just above the logo */
#target-picker {
  bottom: calc(env(safe-area-inset-bottom, 0px) + 30px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: stretch;
  width: 236px;
  padding: 3px;
  text-align: center;
}
#target-picker.hidden { display: none; }
#target-picker button {
  flex: 0 0 38px;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 16px;
  padding: 0;
}
#target-picker button:active { background: rgba(255, 255, 255, 0.28); }
/* Flint arrowhead: pale stone blade with a dark edge and simple knapping lines */
.tp-arrowhead { display: block; width: 29px; height: 20px; margin: auto; }
.tp-arrowhead polygon { fill: #e8e2d6; stroke: #111; stroke-width: 1; stroke-linejoin: round; }
.tp-arrowhead path { stroke: rgba(0, 0, 0, 0.35); stroke-width: 0.8; stroke-linecap: round; }
.tp-arrowhead.flip { transform: scaleX(-1); }
#tp-label { flex: 1; min-width: 0; padding: 3px 2px; line-height: 1.15; }
#tp-num { font-size: 14px; font-weight: 700; color: #00e5ff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#tp-info { font-size: 12px; font-variant-numeric: tabular-nums; }

/* Selected target and the aiming line */
.tgt.selected .face { filter: drop-shadow(0 0 4px #00e5ff) drop-shadow(0 0 2px #00e5ff); }
.tgt.selected .tgt-num { background: #000; border-color: #00e5ff; color: #00e5ff; transform: scale(1.25); }
.tgt.selected .face { outline: 3px solid #00e5ff; outline-offset: 2px; border-radius: 50%; }
.aim-icon { background: none; border: 0; }
.aim-arrow { width: 22px; height: 22px; display: block; }

/* Lane lines: target number on the shooting line */
.lane-icon { background: none; border: 0; }
.lane-label {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #111;
  color: #111;
  font-size: 12px;
  font-weight: 800;
  line-height: 18px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}
/* Selected: inverted (dark with a cyan ring) and larger, so it doesn't depend on seeing the colour */
.lane-label.selected { background: #000; color: #00e5ff; border-color: #00e5ff; transform: scale(1.3); }

/* Safety overlay labels (js/safetyLayer.js), centred on their point */
.zone-icon { background: none; border: 0; }
.zone-label {
  position: absolute;
  transform: translate(-50%, -50%);
  white-space: nowrap;
  padding: 1px 6px;
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.6);
  color: #bbdefb;
  font-size: 11px;
  font-weight: 700;
  pointer-events: none;
}
.zone-label.shooting { color: #f0e442; }
.zone-label.danger { color: #ffa36b; }

/* Field bottom sheet: half the screen, map stays visible and usable above it */
.numbering { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.numbering-label { color: #ccc; font-size: 15px; }
.numbering .segmented { flex: 1; }
.averaging select { flex: 1; width: auto; }
.numbering.field-name { margin: 0 0 8px; }
.numbering.field-name input { flex: 1; width: auto; }
/* Field depth row: number input with its unit */
.depth-cell { display: flex; align-items: center; gap: 8px; color: #ccc; font-size: 15px; }
.depth-cell input { width: 90px; flex: 0 0 auto; }
/* Targets face switch: an arrow turned to each bearing */
.modal-card button.seg.facing { font-variant-numeric: tabular-nums; }
.facing-arrow { display: inline-block; font-weight: 700; }
/* Sun section in Field (js/sun.js): rule check, event window, glare summary and map preview */
/* Dark native controls (date/time pickers, sliders) to match the dialogs */
.modal-card { color-scheme: dark; }
.sun-section { margin-top: 14px; padding-top: 10px; border-top: 1px solid #3a3a3c; }
.sun-section h3 { margin: 0 0 6px; font-size: 16px; }
.sun-rule, .sun-summary { margin: 6px 0; font-size: 14px; color: #ccc; }
.sun-rule.warn, .sun-summary.warn { color: #ffb74d; font-weight: 600; }
.sun-row input[type=date], .sun-row input[type=time] { width: auto; flex: 0 1 auto; }
.sun-row input[type=range] { flex: 1; width: auto; padding: 0; }
.sun-to { color: #ccc; font-size: 15px; }
.sun-at { display: block; margin: 4px 0 2px; color: #ffd400; font-size: 14px; font-variant-numeric: tabular-nums; }
/* Sun marker on the map (js/sunLayer.js) */
.sun-icon { background: none; border: 0; }
.sun-svg { width: 40px; height: 40px; display: block; }
.sun-label {
  position: absolute;
  top: 40px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  padding: 1px 6px;
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.65);
  color: #ffd400;
  font-size: 11px;
  font-weight: 700;
}
.modal-card button.here:disabled { opacity: 0.35; }

/* GPS averaging progress in Field (replaces the size summary while running) */
.avg-panel {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
  z-index: 2;
  padding: 10px;
  border-radius: 10px;
  background: #1b2a3a;
  border: 1px solid #1e88e5;
  box-shadow: 0 -4px 14px rgba(0, 0, 0, 0.6);
}
.avg-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.avg-title { font-weight: 700; }
.modal-card button.avg-cancel { padding: 6px 12px; font-size: 14px; }
.avg-bar { height: 10px; margin: 8px 0 6px; border-radius: 5px; background: #2c2c2e; overflow: hidden; }
.avg-fill { height: 100%; width: 0; background: #1e88e5; transition: width 0.2s linear; }
.avg-text { color: #ccc; font-size: 14px; font-variant-numeric: tabular-nums; }
.modal-backdrop.sheet { align-items: flex-end; padding: 0; background: none; pointer-events: none; }
.modal-backdrop.sheet .modal-card {
  pointer-events: auto;
  max-width: none;
  height: 50dvh;
  max-height: 50dvh;
  padding: 12px 14px calc(env(safe-area-inset-bottom, 0px) + 12px);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.55);
}
.modal-card > div.sheet-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; overflow: visible; flex: 0 0 auto; }
.sheet-header h2 { margin: 0; }
.sheet-header .modal-actions { margin: 0; }
/* Desktop: the sheet's title bar is a drag handle (ui.js, makeDraggable) */
.drag-handle { cursor: grab; user-select: none; touch-action: none; }
.drag-handle:active { cursor: grabbing; }
/* Desktop floating panels (Targets): no dimmed backdrop, so the map stays visible and usable */
.modal-backdrop.floating:not(.sheet) { background: none; pointer-events: none; }
.modal-backdrop.floating .modal-card { pointer-events: auto; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.6); }
.modal-backdrop.sheet .modal-card { position: relative; }
/* Wide screens (desktop, landscape tablets): a compact panel floating above the picker and logo
   instead of a full-width half-screen sheet. Its height fits the content, up to half the screen. */
@media (min-width: 700px) {
  .modal-backdrop.sheet { justify-content: center; padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 90px); }
  .modal-backdrop.sheet .modal-card {
    max-width: 520px;
    height: auto;
    padding-bottom: 14px;
    border-radius: 16px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.6);
  }
}
.sheet-body { overflow-y: auto; min-height: 0; }
/* Thin dark scrollbars that match the dialogs instead of the browser's light default */
.sheet-body, .table-wrap { scrollbar-width: thin; scrollbar-color: #555 transparent; }
.sheet-body::-webkit-scrollbar, .table-wrap::-webkit-scrollbar { width: 6px; }
.sheet-body::-webkit-scrollbar-thumb, .table-wrap::-webkit-scrollbar-thumb { background: #555; border-radius: 3px; }
.sheet-body::-webkit-scrollbar-track, .table-wrap::-webkit-scrollbar-track { background: transparent; }

/* Long target lists: keep the scrollbar off the delete buttons and make them easy to hit */
.table-wrap { padding-right: 14px; }
table.targets:not(.field) th:nth-child(5), table.targets:not(.field) td:nth-child(5) { width: 52px; padding-left: 2px; }
.modal-card button.del { width: 44px; height: 44px; padding: 0; font-size: 18px; }
table.targets:not(.field) td { padding-top: 3px; padding-bottom: 3px; }

/* Targets column widths: narrow number and shooters (1-4), room for the division names */
table.targets:not(.field) { table-layout: fixed; width: 100%; }
table.targets:not(.field) th:nth-child(1) { width: 12%; }
table.targets:not(.field) th:nth-child(2) { width: 15%; }
table.targets:not(.field) th:nth-child(3) { width: 20%; }
table.targets:not(.field) th:nth-child(4) { width: 37%; }
table.targets:not(.field) th:nth-child(5) { width: 16%; }
table.targets:not(.field) td:nth-child(4) select { text-overflow: ellipsis; }
table.targets:not(.field) select { width: 100%; min-width: 0; padding-left: 6px; padding-right: 2px; text-align: left; }
table.targets:not(.field) td:nth-child(5) { text-align: center; padding-left: 0; padding-right: 0; }
.modal-card button.del { margin: 0 auto; display: block; }
/* Setup sheet (js/setupSheet.js): shown in the Print preview and, alone, on paper */
#print-root { display: none; }
.sheet-preview { background: #fff; color: #111; border-radius: 8px; padding: 12px; overflow: auto; }
.setup-sheet { font: 12px/1.35 system-ui, sans-serif; color: #111; }
.setup-sheet h1 { font-size: 18px; margin: 0 0 2px; }
.setup-sheet h2 { font-size: 14px; margin: 14px 0 4px; border-bottom: 1px solid #999; }
.setup-sheet header p { margin: 0 0 8px; color: #444; }
.setup-sheet ul { margin: 4px 0; padding-left: 18px; }
.setup-sheet li { margin: 2px 0; }
.setup-sheet table { border-collapse: collapse; width: 100%; }
.setup-sheet table.narrow { width: auto; }
.setup-sheet th, .setup-sheet td { border: 1px solid #bbb; padding: 3px 5px; text-align: left; vertical-align: top; }
.setup-sheet thead th { background: #eee; }
.setup-sheet td.n { text-align: right; white-space: nowrap; }
.setup-sheet .mono { font-family: ui-monospace, Consolas, monospace; white-space: nowrap; }
.setup-sheet .ss-diagram { display: block; width: 100%; max-width: 680px; height: auto; margin: 4px auto; }
.setup-sheet .foot { margin-top: 12px; color: #666; font-size: 10px; }

/* Light mode: the menu and its dialogs (Save, Open, Export, Print, Field, Targets) follow the system
   light/dark setting. Dark is the default above; this only applies when the system asks for light.
   Map overlays (menu button, compass, picker, search, labels) stay dark for contrast on imagery. */
@media (prefers-color-scheme: light) {
  #menu { background: rgba(255, 255, 255, 0.94); color: #111; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35); }
  #menu button { color: #111; }
  #menu button:active { background: rgba(0, 0, 0, 0.08); }
  .menu-divider { background: rgba(0, 0, 0, 0.15); }
  #menu button.temp { color: #666; border-top-color: rgba(0, 0, 0, 0.12); }

  .modal-backdrop:not(.floating) { background: rgba(0, 0, 0, 0.35); }
  .modal-card { background: #f5f5f7; color: #111; color-scheme: light; }
  .modal-card button { background: #e3e3e8; color: #111; }
  .modal-card button.primary { background: #1e88e5; color: #fff; }
  .modal-card input, .modal-card select { background: #fff; color: #111; border-color: #c7c7cc; }
  .modal-card input.invalid { background: #fdecec; border-color: #d32f2f; }
  table.targets th { background: #f5f5f7; color: #555; }
  .field-label, .share-note, .lane-summary, .numbering-label, .depth-cell, .sun-to, .avg-text, .empty { color: #444; }
  .sun-rule, .sun-summary { color: #444; }
  /* Warnings: a darker amber that reads on light grey */
  .lane-summary.over, .sun-rule.warn, .sun-summary.warn { color: #a15c00; }
  .sun-at { color: #8a6500; }

  .segmented { border-color: #c7c7cc; }
  .modal-card button.seg { background: #e3e3e8; color: #111; }
  .modal-card button.seg + button.seg { border-left-color: #c7c7cc; }
  .modal-card button.seg.active { background: #1e88e5; color: #fff; }
  .modal-card button.del { background: #f3d6d6; color: #8e2b2b; }
  .saved-list .delete { background: #c62828; color: #fff; }

  .sun-section { border-top-color: #d1d1d6; }
  .avg-panel { background: #e6f0fb; box-shadow: 0 -4px 14px rgba(0, 0, 0, 0.2); }
  .avg-bar { background: #d1d1d6; }
  .sheet-body, .table-wrap { scrollbar-color: #b8b8bd transparent; }
  .sheet-body::-webkit-scrollbar-thumb, .table-wrap::-webkit-scrollbar-thumb { background: #b8b8bd; }
  .modal-backdrop.sheet .modal-card, .modal-backdrop.floating .modal-card { box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35); }
}

@media print {
  @page { margin: 12mm; }
  html, body { background: #fff !important; height: auto; overflow: visible; }
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block; }
  .setup-sheet tr { break-inside: avoid; }
  .setup-sheet h2 { break-after: avoid; }
}
