body {
  font-family: Arial, sans-serif;
  margin: 0;
  padding: 0;
  background-color: #f8f9fa;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 10px;
}

@media (min-width: 769px) {
  .container {
    padding: 20px;
  }
}

h1 {
  color: #0c5460;
  margin-bottom: 10px;
  font-size: 24px;
}

@media (min-width: 769px) {
  h1 {
    font-size: 32px;
  }
}

.course-builder {
  background: #f5f5f5;
  padding: 10px;
  border-radius: 8px;
  margin-bottom: 10px;
}

@media (min-width: 769px) {
  .course-builder {
    padding: 20px;
    margin-bottom: 20px;
  }
}

/* Message parser styling */
.message-parser {
  margin-bottom: 20px;
}

.message-parser textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-family: monospace;
  font-size: 14px;
  resize: vertical;
}

.message-parser button {
  background: #4CAF50;
  color: white;
  padding: 10px 20px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  margin-top: 10px;
  font-size: 16px;
}

.message-parser button:hover {
  background: #45a049;
}

/* Validation styling */
.parsed-course {
  background: #fff3cd;
  padding: 15px;
  border-radius: 4px;
  border: 1px solid #ffeaa7;
  margin: 20px 0;
}

.parsed-mark {
  display: flex;
  align-items: center;
  margin: 8px 0;
  padding: 8px;
  background: white;
  border-radius: 4px;
  border: 1px solid #e0e0e0;
}

.mark-number {
  background: #007bff;
  color: white;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 10px;
  font-weight: bold;
  flex-shrink: 0;
}

.mark-info {
  flex-grow: 1;
  margin-right: 10px;
}

.original-text {
  font-style: italic;
  color: #666;
  margin-right: 10px;
  font-size: 0.9em;
}

.edit-btn, .delete-btn {
  padding: 4px 8px;
  margin-left: 5px;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  font-size: 14px;
}

.edit-btn {
  background: #ffc107;
  color: #212529;
}

.edit-btn:hover {
  background: #e0a800;
}

.delete-btn {
  background: #dc3545;
  color: white;
}

.delete-btn:hover {
  background: #c82333;
}

.validation-note {
  margin: 15px 0;
  padding: 10px;
  background: #d1ecf1;
  border-radius: 4px;
  color: #0c5460;
  border: 1px solid #bee5eb;
}

/* Quick Add Section */
.quick-add-section {
  background: #e3f2fd;
  padding: 10px;
  border-radius: 8px;
  margin: 10px 0;
  border: 1px solid #90caf9;
}

.quick-add-section h3 {
  margin: 0 0 10px 0;
  color: #1976d2;
  font-size: 18px;
}

.rounding-selector {
  margin-bottom: 10px;
  padding: 8px;
  background: white;
  border-radius: 4px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
}

.rounding-selector label {
  margin-right: 10px;
  font-weight: normal;
  font-size: 14px;
}

.rounding-selector input[type="radio"] {
  margin-right: 3px;
}

.clear-course-btn {
  background: #dc3545;
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  margin-top: 5px;
}

.mark-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  max-height: 50vh;
  overflow-y: auto;
  padding: 8px;
  background: white;
  border-radius: 4px;
}

.mark-btn {
  padding: 15px 10px;
  border: 2px solid #2196F3;
  background: white;
  color: #2196F3;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
  font-size: 18px;
  text-align: center;
  transition: all 0.2s;
}

.mark-btn:hover {
  background: #2196F3;
  color: white;
}

.mark-btn:active {
  transform: scale(0.95);
}

.mark-btn.added {
  background: #4CAF50;
  color: white;
  border-color: #4CAF50;
}

/* Desktop optimization */
@media (min-width: 769px) {
  .quick-add-section {
    padding: 20px;
    margin: 20px 0;
  }
  
  .quick-add-section h3 {
    font-size: 20px;
    margin-bottom: 15px;
  }
  
  .rounding-selector {
    padding: 10px;
    margin-bottom: 15px;
  }
  
  .rounding-selector label {
    margin-right: 15px;
    font-size: 16px;
  }
  
  .rounding-selector input[type="radio"] {
    margin-right: 5px;
  }
  
  .mark-grid {
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 8px;
    max-height: 400px;
    padding: 10px;
  }
  
  .mark-btn {
    padding: 12px 8px;
    font-size: 16px;
  }
}

/* Manual selector styling */
.mark-selector {
  background: #e9ecef;
  padding: 15px;
  border-radius: 4px;
  margin: 20px 0;
}

.mark-selector h3 {
  margin-top: 0;
  color: #495057;
}

.mark-selector select, .mark-selector button {
  margin: 5px;
  padding: 8px;
  border: 1px solid #ced4da;
  border-radius: 4px;
}

.mark-selector button {
  background: #6c757d;
  color: white;
  border: none;
  cursor: pointer;
}

.mark-selector button:hover {
  background: #5a6268;
}

/* Course list styling */
.course-list {
  margin: 20px 0;
}

.course-list ul {
  background: white;
  padding: 15px;
  border-radius: 4px;
  border: 1px solid #ddd;
  list-style: none;
  margin: 10px 0;
}

.course-list li {
  padding: 5px 0;
  border-bottom: 1px solid #f0f0f0;
}

.course-list li:last-child {
  border-bottom: none;
}

/* Start Line Section */
.start-line-section {
  margin: 20px 0;
  padding: 15px;
  background: #f0f8ff;
  border-radius: 4px;
  border: 1px solid #b0d4f1;
}

.start-line-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 10px;
}

.ping-btn {
  padding: 8px 15px;
  background: #17a2b8;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}

.ping-btn:hover {
  background: #138496;
}

.ping-btn:disabled {
  background: #6c757d;
  cursor: not-allowed;
}

.ping-status {
  font-size: 14px;
  color: #28a745;
}

.clear-btn {
  padding: 8px 15px;
  background: #dc3545;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}

.clear-btn:hover {
  background: #c82333;
}

.start-line-info {
  margin-top: 10px;
  padding: 10px;
  background: #d4edda;
  border-radius: 4px;
  border: 1px solid #c3e6cb;
}

/* Wind input */
.wind-input {
  margin: 20px 0;
  padding: 15px;
  background: #e3f2fd;
  border-radius: 4px;
  border: 1px solid #90caf9;
}

/* Map styling */
.map-container {
  position: relative;
  margin: 20px 0;
}

/* Wind direction marker */
.wind-direction-marker {
  pointer-events: none;
  z-index: 1000 !important;
}

#map {
  height: 500px;
  border-radius: 8px;
  border: 2px solid #ddd;
}

/* Fullscreen button */
.fullscreen-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1000;
  background: white;
  border: 2px solid rgba(0,0,0,0.2);
  border-radius: 4px;
  padding: 8px;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 5px rgba(0,0,0,0.4);
}

.fullscreen-btn:hover {
  background: #f0f0f0;
}

/* Fullscreen mode styles */
.map-container.fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  margin: 0;
  background: white;
}

.map-container.fullscreen #map {
  height: 100vh;
  border-radius: 0;
  border: none;
}

.map-container.fullscreen .fullscreen-btn {
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

/* Course marker styling for Leaflet */
.course-marker {
  background-color: transparent !important;
  border: none !important;
}

.marker-number {
  background: red;
  color: white;
  border-radius: 50%;
  width: 25px;
  height: 25px;
  text-align: center;
  line-height: 25px;
  font-weight: bold;
  border: 2px solid white;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.finish-marker .marker-number {
  background: darkblue;
  color: white;
  border: 2px solid gold;
}

/* Position marker styling */
.position-marker {
  background-color: transparent !important;
  border: none !important;
}

.position-dot {
  width: 16px;
  height: 16px;
  background-color: #007bff;
  border: 3px solid white;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.4), 0 2px 6px rgba(0, 0, 0, 0.3);
  position: relative;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.4), 0 2px 6px rgba(0, 0, 0, 0.3);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(0, 123, 255, 0.2), 0 2px 6px rgba(0, 0, 0, 0.3);
  }
  100% {
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.4), 0 2px 6px rgba(0, 0, 0, 0.3);
  }
}

/* Results section */
.course-results {
  background: white;
  padding: 10px;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  margin-top: 20px;
}

@media (min-width: 769px) {
  .course-results {
    padding: 20px;
  }
}

.total-distance {
  font-weight: bold;
  margin: 10px 0;
  padding: 10px;
  background: #e3f2fd;
  border-radius: 4px;
  font-size: 16px;
}

@media (min-width: 769px) {
  .total-distance {
    font-size: 18px;
  }
}

/* Table styling with horizontal scroll on mobile */
.table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 10px -10px;
}

@media (min-width: 769px) {
  .table-container {
    margin: 20px 0;
  }
}

.course-table {
  width: 100%;
  min-width: 600px;
  border-collapse: collapse;
}

.course-table th, .course-table td {
  border: 1px solid #ddd;
  padding: 8px;
  text-align: left;
  white-space: nowrap;
}

@media (min-width: 769px) {
  .course-table th, .course-table td {
    padding: 10px;
    white-space: normal;
  }
}

.course-table th {
  background: #f8f9fa;
  font-weight: bold;
  position: sticky;
  top: 0;
  z-index: 10;
}

.course-table tr:nth-child(even) {
  background-color: #f8f9fa;
}

.course-table tr:hover {
  background-color: #e9ecef;
}

/* Make specific columns narrower on mobile */
@media (max-width: 768px) {
  .course-table td:nth-child(1), /* Leg */
  .course-table th:nth-child(1) {
    width: 40px;
  }
  
  .course-table td:nth-child(2), /* Mark ID */
  .course-table th:nth-child(2) {
    width: 50px;
  }
  
  .course-table td:nth-child(3), /* Mark Name */
  .course-table th:nth-child(3) {
    font-size: 14px;
    max-width: 120px;
    white-space: normal;
    word-break: break-word;
  }
  
  .course-table td:nth-child(4), /* Rounding */
  .course-table th:nth-child(4) {
    font-size: 14px;
  }
  
  /* Sail recommendation can wrap */
  .course-table td:nth-child(8),
  .course-table th:nth-child(8) {
    font-size: 14px;
    white-space: normal;
    max-width: 100px;
  }
}

/* Download buttons */
.download-buttons {
  margin-top: 20px;
  text-align: center;
}

.download-buttons button {
  background: #28a745;
  color: white;
  padding: 12px 20px;
  margin: 5px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
}

.download-buttons button:hover {
  background: #218838;
}

/* Responsive design */
@media (max-width: 768px) {
  .parsed-mark {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .mark-number {
    margin-bottom: 10px;
  }
  
  .original-text {
    display: block;
    margin: 10px 0;
  }
  
  .edit-btn, .delete-btn {
    margin: 5px 5px 5px 0;
  }
  
  #map {
    height: 350px;
  }
  
  .course-table {
    font-size: 14px;
  }
  
  .course-table th, .course-table td {
    padding: 6px;
  }
}

/* Modal Styles */
.modal {
  position: fixed;
  z-index: 10000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background-color: white;
  margin: 10px;
  padding: 0;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  width: 90%;
  max-width: 400px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  background-color: #f8f9fa;
  border-bottom: 1px solid #dee2e6;
  border-radius: 8px 8px 0 0;
}

.modal-header h3 {
  margin: 0;
  color: #495057;
}

.close {
  font-size: 28px;
  font-weight: bold;
  color: #aaa;
  cursor: pointer;
  line-height: 20px;
}

.close:hover,
.close:focus {
  color: #000;
}

.modal-body {
  padding: 20px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: bold;
  color: #495057;
}

.form-control {
  width: 100%;
  padding: 10px;
  border: 1px solid #ced4da;
  border-radius: 4px;
  font-size: 16px;
}

.radio-group {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.radio-group label {
  display: flex;
  align-items: center;
  font-weight: normal;
  margin-bottom: 0;
}

.radio-group input[type="radio"] {
  margin-right: 5px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 15px 20px;
  background-color: #f8f9fa;
  border-top: 1px solid #dee2e6;
  border-radius: 0 0 8px 8px;
}

.btn-primary, .btn-secondary {
  padding: 10px 20px;
  border: none;
  border-radius: 4px;
  font-size: 16px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.btn-primary {
  background-color: #007bff;
  color: white;
}

.btn-primary:hover {
  background-color: #0056b3;
}

.btn-secondary {
  background-color: #6c757d;
  color: white;
}

.btn-secondary:hover {
  background-color: #545b62;
}

/* Search Container */
.search-container {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
  padding: 8px;
  background: white;
  border-radius: 4px;
}

#mark-search {
  flex: 1;
  padding: 10px;
  border: 1px solid #ced4da;
  border-radius: 4px;
  font-size: 16px;
}

.clear-search-btn {
  padding: 10px 15px;
  background: #6c757d;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}

.clear-search-btn:hover {
  background: #545b62;
}

/* Footer */
.footer {
  background-color: #2c3e50;
  color: #ecf0f1;
  text-align: center;
  padding: 20px 10px;
  margin-top: 40px;
  border-top: 3px solid #34495e;
}

.footer p {
  margin: 0;
  font-size: 14px;
}

@media (min-width: 769px) {
  .footer {
    padding: 30px 20px;
    margin-top: 60px;
  }
  
  .footer p {
    font-size: 16px;
  }
}