* {
  box-sizing: border-box;
}

html,
body,
#app {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

#map {
  width: 100%;
  height: 100%;
}

.panel {
  position: absolute;
  z-index: 5;
  background: rgba(10, 16, 20, 0.88);
  color: #f0f5f7;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  backdrop-filter: blur(4px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

.panel-title {
  font-weight: 700;
  margin-bottom: 8px;
}

.panel-left {
  top: 12px;
  left: 12px;
  padding: 12px;
  min-width: 268px;
  max-width: min(330px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow-y: auto;
}

.panel-top {
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px;
  width: min(540px, calc(100vw - 40px));
}

.panel-cursor {
  top: 68px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 12px;
  width: min(420px, calc(100vw - 40px));
}

.panel-right {
  top: 12px;
  right: 12px;
  padding: 12px;
  min-width: 300px;
  max-width: min(380px, calc(100vw - 24px));
}

#course-search {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  font-size: 15px;
  outline: none;
  background: rgba(255, 255, 255, 0.93);
}

.cursor-distance-row {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  font-size: 13px;
  font-weight: 700;
}

.cursor-prev {
  color: #7dd3fc;
}

.cursor-hole {
  color: #86efac;
}

.controls-grid {
  display: grid;
  gap: 6px;
  font-size: 13px;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  margin-bottom: 10px;
}

.mode-btn {
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  padding: 6px 7px;
  font-size: 12px;
  cursor: pointer;
  background: rgba(31, 122, 93, 0.9);
  color: #f2fff9;
}

.mode-btn:hover {
  background: rgba(27, 106, 81, 0.95);
}

.mode-btn.active {
  border-color: rgba(187, 247, 208, 0.95);
  box-shadow: 0 0 0 1px rgba(134, 239, 172, 0.62);
}

.mode-btn.mode-btn-secondary {
  background: rgba(55, 65, 81, 0.95);
  color: #ecf2f8;
}

.mode-btn.mode-btn-secondary:hover {
  background: rgba(43, 52, 66, 0.95);
}

.aimpoint-panel {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  display: grid;
  gap: 7px;
}

#aim-preview-canvas {
  width: 100%;
  max-width: 244px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(8, 12, 18, 0.92);
}

.aim-preview-distance {
  font-size: 11px;
  color: #b5cad7;
}

.aim-origin-row {
  display: grid;
  gap: 6px;
}

.aim-origin-status {
  font-size: 12px;
  color: #d4e5ef;
}

.aim-origin-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.aim-origin-actions button,
#aim-run-btn {
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  padding: 7px 8px;
  font-size: 12px;
  cursor: pointer;
}

.aim-origin-actions button {
  background: rgba(30, 83, 117, 0.9);
  color: #e2f5ff;
}

.aim-origin-actions button:hover {
  background: rgba(25, 69, 98, 0.96);
}

#aim-run-btn {
  margin-top: 2px;
  background: #17784f;
  color: #edfff7;
}

#aim-run-btn:hover {
  background: #146444;
}

#aim-run-btn:disabled,
.aim-origin-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.aim-slider-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: #d4e5ef;
}

#aim-ns-slider,
#aim-ew-slider,
#aim-rough-mult-slider,
#aim-tilt-slider,
#aim-max-slider {
  width: 100%;
}

#aim-max-slider:disabled {
  opacity: 0.5;
}

.aim-result-status {
  margin-top: 1px;
  font-size: 11px;
  line-height: 1.35;
  color: #bed3df;
}

.aim-surface-legend {
  margin-top: 2px;
  display: grid;
  gap: 4px;
  font-size: 11px;
  color: #d6e5ed;
}

.aim-surface-legend-item {
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: center;
  gap: 6px;
}

.aim-surface-swatch {
  width: 11px;
  height: 11px;
  border-radius: 2px;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.aim-surface-swatch-best {
  background: #1e40af;
}

.aim-surface-swatch-mid {
  background: #facc15;
}

.aim-surface-swatch-worst {
  background: #dc2626;
}

.aim-surface-legend-label {
  color: #aecdde;
}

kbd {
  border: 1px solid #93a3ad;
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 2px 6px;
  display: inline-block;
  min-width: 26px;
  text-align: center;
  background: #25323a;
  color: #f3f8fb;
}

#status {
  display: grid;
  gap: 8px;
  font-size: 14px;
}

.auto-lie-panel {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.around-hole-panel {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.around-hole-summary {
  margin-top: 8px;
  font-size: 12px;
  color: #c6d8e3;
  line-height: 1.4;
}

.auto-lie-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #d8e7ef;
}

.auto-lie-toggle + .auto-lie-toggle {
  margin-top: 6px;
}

.auto-lie-status {
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.35;
  color: #a8bdc9;
}

.auto-lie-status[data-tone="loading"] {
  color: #93c5fd;
}

.auto-lie-status[data-tone="ok"] {
  color: #86efac;
}

.auto-lie-status[data-tone="warn"] {
  color: #fde68a;
}

.auto-lie-status[data-tone="error"] {
  color: #fca5a5;
}

#auto-lie-refresh-btn {
  margin-top: 8px;
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  cursor: pointer;
}

.custom-zone-panel {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.custom-zone-grid {
  margin-top: 6px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.custom-zone-grid button,
#custom-ob-delete-btn,
#polygon-save-btn {
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 12px;
  cursor: pointer;
}

#custom-ob-start-btn {
  background: #9f1239;
  color: #ffe4e6;
}

#custom-ob-start-btn:hover {
  background: #881337;
}

#custom-ob-start-btn.active {
  background: #dc2626;
  border-color: rgba(254, 202, 202, 0.8);
}

#polygon-save-btn {
  background: #166534;
  color: #e9fff4;
}

#polygon-save-btn:hover {
  background: #14532d;
}

#custom-ob-delete-btn {
  margin-top: 6px;
  width: 100%;
}

#custom-ob-delete-btn.active {
  background: #dc2626;
  color: #ffe4e6;
  border-color: rgba(254, 202, 202, 0.85);
}

.polygon-brush-mode {
  margin-top: 6px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.zone-select-label {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  color: #aecdde;
}

.polygon-slider-row {
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: #d9e9f4;
}

#tree-penalty-slider {
  width: 100%;
  margin-top: 4px;
}

#tree-penalty-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  color: #d1fae5;
}

.saved-rounds-panel {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.saved-rounds-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.saved-rounds-actions #save-round-btn,
.saved-rounds-actions #load-round-file-btn {
  margin-top: 0;
}

.saved-rounds-list {
  margin-top: 8px;
  max-height: 220px;
  overflow: auto;
  display: grid;
  gap: 8px;
}

.saved-round-empty {
  font-size: 12px;
  color: #9db2bf;
}

.saved-round-item {
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 7px;
  background: rgba(21, 30, 39, 0.9);
  display: grid;
  gap: 6px;
}

.saved-round-name {
  font-size: 12px;
  font-weight: 700;
  color: #f2f8fb;
}

.saved-round-info {
  font-size: 11px;
  color: #9cb5c3;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.saved-round-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.saved-round-row-actions button {
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(12, 20, 27, 0.84);
  color: #e7f1f7;
  border-radius: 6px;
  padding: 4px 7px;
  font-size: 11px;
  cursor: pointer;
}

.saved-round-row-actions button:hover {
  border-color: rgba(165, 224, 255, 0.8);
  background: rgba(19, 38, 52, 0.9);
}

#finish-btn,
#next-hole-btn,
#close-analytics,
#save-round-btn,
#load-round-file-btn {
  margin-top: 10px;
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  cursor: pointer;
  background: #1f7a5d;
  color: #f2fff9;
}

#finish-btn:hover,
#next-hole-btn:hover,
#close-analytics:hover {
  background: #1b6a51;
}

#save-round-btn {
  background: #6d4bc3;
  color: #f3ecff;
}

#save-round-btn:hover {
  background: #5a3fa2;
}

#next-hole-btn {
  background: #205f94;
  color: #e7f5ff;
}

#next-hole-btn:hover {
  background: #194f7b;
}

.button-secondary {
  background: #374151;
  color: #e5e7eb;
}

.button-secondary:hover {
  background: #2b3442;
}

#analytics-page {
  position: absolute;
  inset: 0;
  z-index: 10;
  background: rgba(3, 8, 12, 0.95);
  overflow: auto;
}

.analytics-shell {
  min-height: 100%;
  padding: 18px;
  color: #f2f8fb;
}

.analytics-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.analytics-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.analytics-header h2 {
  margin: 0;
}

.analytics-header p {
  margin: 6px 0 0;
}

#close-analytics {
  width: auto;
  margin-top: 0;
  padding: 10px 16px;
}

#clear-shot-focus {
  width: auto;
  margin-top: 0;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 8px;
  cursor: pointer;
}

.analytics-dashboard {
  margin-top: 14px;
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
}

.analytics-card {
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  background: rgba(22, 33, 42, 0.85);
  padding: 10px;
}

.analytics-card h3 {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 600;
  color: #d4e5ef;
}

.analytics-card .value {
  font-size: 25px;
  font-weight: 700;
}

.value-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
}

.bucket-filter-btn {
  border: 1px solid rgba(203, 221, 232, 0.45);
  background: rgba(14, 23, 30, 0.7);
  color: #e2edf4;
  width: 28px;
  height: 24px;
  border-radius: 8px;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}

.bucket-filter-btn:hover {
  border-color: rgba(148, 223, 255, 0.9);
  background: rgba(22, 47, 66, 0.8);
}

.bucket-filter-btn.active {
  border-color: rgba(123, 227, 255, 1);
  background: rgba(27, 70, 94, 0.85);
}

.eye-icon {
  width: 13px;
  height: 7px;
  border: 1.6px solid currentColor;
  border-radius: 999px;
  position: relative;
  display: inline-block;
}

.eye-icon::after {
  content: "";
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 999px;
  background: currentColor;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.analytics-card .count {
  margin-top: 2px;
  font-size: 12px;
  color: #9db2bf;
}

.sg-positive {
  color: #4ade80;
}

.sg-negative {
  color: #f87171;
}

.sg-neutral {
  color: #f5f5f5;
}

.value.sg-positive {
  color: #4ade80;
}

.value.sg-negative {
  color: #f87171;
}

.value.sg-neutral {
  color: #f5f5f5;
}

.scorecard-sections {
  margin-top: 14px;
  display: grid;
  gap: 12px;
}

.scorecard-wrap {
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  overflow: auto;
  background: rgba(16, 23, 31, 0.9);
}

.scorecard-title {
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 700;
  background: rgba(32, 47, 60, 0.9);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.scorecard-table {
  border-collapse: collapse;
  width: max-content;
  min-width: 100%;
}

.scorecard-table th,
.scorecard-table td {
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 6px 8px;
  text-align: center;
  vertical-align: top;
  min-width: 100px;
  font-size: 12px;
}

.scorecard-table th.row-label,
.scorecard-table td.row-label {
  position: sticky;
  left: 0;
  z-index: 2;
  text-align: left;
  min-width: 130px;
  background: #16222d;
  font-weight: 700;
}

.scorecard-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #1a2833;
}

.scorecard-table thead th.row-label {
  z-index: 3;
}

.hole-sg.sg-positive {
  color: #4ade80;
  font-weight: 700;
}

.hole-sg.sg-negative {
  color: #f87171;
  font-weight: 700;
}

.hole-sg.sg-neutral {
  color: #f5f5f5;
  font-weight: 700;
}

.shot-list {
  display: grid;
  gap: 4px;
}

.shot-row {
  display: grid;
  grid-template-columns: 1fr auto;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  overflow: hidden;
  font-size: 11px;
  transition: opacity 120ms ease;
}

.shot-row.is-dimmed {
  opacity: 0.28;
}

.shot-row.is-focused-shot {
  opacity: 1;
  border-color: rgba(156, 255, 171, 0.95);
  box-shadow: 0 0 0 1px rgba(86, 214, 107, 0.75);
}

.shot-left,
.shot-right {
  padding: 3px 5px;
}

.shot-left {
  text-align: left;
}

.shot-right {
  min-width: 44px;
  border-left: 1px solid rgba(255, 255, 255, 0.15);
  font-weight: 700;
}

.shot-right.sg-positive {
  color: #4ade80;
}

.shot-right.sg-negative {
  color: #f87171;
}

.shot-right.sg-neutral {
  color: #f5f5f5;
}

.shot-cat-teeLong .shot-left {
  background: rgba(239, 68, 68, 0.28);
}

.shot-cat-approachLong .shot-left {
  background: rgba(74, 222, 128, 0.24);
}

.shot-cat-shortGame .shot-left {
  background: rgba(56, 189, 248, 0.26);
}

.shot-cat-putting .shot-left {
  background: rgba(250, 204, 21, 0.3);
  color: #fffceb;
}

.shot-cat-none .shot-left {
  background: rgba(148, 163, 184, 0.2);
}

.shot-action-menu {
  position: fixed;
  z-index: 12;
  width: 220px;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(7, 12, 17, 0.94);
  color: #e7f1f7;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35);
}

.shot-action-title {
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 8px;
}

.shot-action-label {
  display: block;
  font-size: 11px;
  color: #9fb5c3;
  margin-bottom: 4px;
}

.shot-lie-select {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  background: rgba(18, 27, 35, 0.95);
  color: #eff6fb;
  padding: 7px;
  font-size: 13px;
}

.shot-action-buttons {
  margin-top: 10px;
  display: grid;
  gap: 6px;
}

.shot-action-buttons button {
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  background: rgba(31, 122, 93, 0.9);
  color: #f2fff9;
  cursor: pointer;
  padding: 7px 8px;
  font-size: 12px;
}

.shot-action-buttons button:hover {
  background: rgba(27, 106, 81, 0.95);
}

.mobile-controls {
  display: none;
  position: fixed;
  left: 8px;
  right: 8px;
  bottom: 8px;
  z-index: 9;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  background: rgba(7, 12, 17, 0.94);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.42);
  padding: 8px;
  gap: 6px;
}

.mobile-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.mobile-btn {
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  background: rgba(25, 43, 56, 0.92);
  color: #edf6fc;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1;
  min-height: 34px;
}

.mobile-btn.active {
  border-color: rgba(167, 243, 208, 0.95);
  background: rgba(21, 128, 61, 0.85);
  color: #effff7;
}

.mobile-btn.mobile-btn-secondary {
  background: rgba(55, 65, 81, 0.9);
  color: #e5ebf1;
}

.mobile-drop-status {
  font-size: 11px;
  color: #bfdae8;
  line-height: 1.35;
  padding: 2px 2px 0;
}

.hidden {
  display: none !important;
}

@media (max-width: 880px) {
  .panel-top {
    top: 8px;
    width: calc(100vw - 16px);
    left: 8px;
    transform: none;
  }

  .panel-cursor {
    top: 62px;
    left: 8px;
    transform: none;
    width: calc(100vw - 16px);
    padding: 6px 8px;
  }

  .mobile-controls {
    display: grid;
  }

  .panel-left,
  .panel-right {
    display: none;
    position: fixed;
    left: 8px;
    right: 8px;
    top: auto;
    bottom: 126px;
    width: auto;
    min-width: 0;
    max-width: none;
    max-height: min(58vh, 520px);
    z-index: 8;
  }

  #app.mobile-show-left .panel-left {
    display: block;
  }

  #app.mobile-show-right .panel-right {
    display: block;
  }

  .analytics-dashboard {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }

  .scorecard-table th,
  .scorecard-table td {
    min-width: 88px;
    font-size: 11px;
  }

  .scorecard-table th.row-label,
  .scorecard-table td.row-label {
    min-width: 114px;
  }
}
