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

:root {
  --green-900: #14532d;
  --green-800: #166534;
  --green-700: #15803d;
  --green-600: #16a34a;
  --green-500: #22c55e;
  --green-400: #4ade80;
  --green-100: #dcfce7;
  --green-50: #f0fdf4;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --red-500: #ef4444;
  --red-100: #fee2e2;
  --yellow-500: #eab308;
  --yellow-100: #fef9c3;
  --orange-500: #f97316;
  --blue-500: #3b82f6;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Header */
.header {
  background: var(--green-800);
  color: white;
  padding: 12px 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-md);
}

.header-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.header h1 a {
  color: white;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-logo {
  height: 50px;
  width: auto;
  display: block;
}

.header-title-group {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.header-title {
  font-size: 22px;
  font-weight: 700;
  color: white;
}

.header-subtitle {
  font-size: 14px;
  font-weight: 400;
  color: var(--green-400);
}

.header h1 span {
  color: var(--green-400);
}

/* Hero banner */
.hero-banner {
  background: #1e5c1e;
  color: white;
  text-align: center;
  font-size: 24px;
  font-weight: 400;
  padding: 20px 16px;
  line-height: 1.4;
}

/* Weather bar */
.weather-bar {
  background: var(--green-100);
  border-bottom: 1px solid var(--green-400);
  padding: 8px 16px;
  font-size: 0.875rem;
  color: var(--green-900);
}

.weather-bar-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
}

.weather-bar-location {
  font-weight: 700;
}

.weather-bar-item {
  white-space: nowrap;
}

.rain-low { color: var(--green-700); }
.rain-possible { color: var(--orange-500); }
.rain-likely { color: var(--red-500); }

/* Hourly forecast */
.hourly-forecast {
  background: var(--green-800);
  padding: 16px;
  margin-top: 24px;
}

.hourly-forecast-inner {
  max-width: 960px;
  margin: 0 auto;
}

.hourly-forecast-label {
  color: white;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 10px;
}

.hourly-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  -webkit-overflow-scrolling: touch;
}

.hourly-scroll::-webkit-scrollbar {
  height: 4px;
}

.hourly-scroll::-webkit-scrollbar-thumb {
  background: var(--green-500);
  border-radius: 4px;
}

.hourly-card {
  flex: 0 0 72px;
  background: rgba(255,255,255,0.1);
  border-radius: var(--radius);
  padding: 8px 6px;
  text-align: center;
  color: white;
  font-size: 0.75rem;
}

.hourly-time {
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--green-400);
}

.hourly-icon {
  font-size: 1.25rem;
  margin-bottom: 2px;
}

.hourly-temp {
  font-weight: 700;
  font-size: 0.8125rem;
  margin-bottom: 2px;
}

.hourly-rain {
  color: rgba(255,255,255,0.7);
  font-size: 0.6875rem;
}

/* Court map */
.court-map {
  height: 400px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  z-index: 0;
}

.view-toggle {
  display: none;
  width: 100%;
  padding: 10px;
  margin-bottom: 12px;
  border: 2px solid var(--green-600);
  border-radius: var(--radius);
  background: white;
  color: var(--green-800);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  text-align: center;
}

.view-toggle:hover {
  background: var(--green-50);
}

@media (max-width: 767px) {
  .view-toggle {
    display: block;
  }
  .court-map {
    display: none;
    height: calc(100vh - 200px);
    margin-bottom: 0;
  }
  .court-map.mobile-visible {
    display: block;
  }
  .court-list.mobile-hidden {
    display: none;
  }
}

.header nav {
  display: flex;
  gap: 8px;
}

.header nav a {
  color: white;
  text-decoration: none;
  font-size: 0.875rem;
  padding: 6px 12px;
  border-radius: var(--radius);
  transition: background 0.15s;
}

.header nav a:hover {
  background: rgba(255,255,255,0.15);
}

.nav-add {
  background: var(--green-600) !important;
  font-weight: 600;
}

.nav-add:hover {
  background: var(--green-500) !important;
}

/* Main content */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px;
}

/* Page titles */
.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--green-900);
  margin-bottom: 16px;
}

/* Filters */
.filters {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filters select,
.filters input[type="text"] {
  flex: 1;
  min-width: 120px;
  padding: 10px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 0.9375rem;
  background: white;
  color: var(--gray-700);
  font-family: inherit;
}

.filter-checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.875rem;
  color: var(--gray-700);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

.filter-checkbox input {
  accent-color: var(--green-600);
  width: 16px;
  height: 16px;
}

.filters select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.filters input[type="text"]:focus {
  outline: none;
  border-color: var(--green-500);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15);
}

.filters input[type="text"] {
  flex: 2;
}

/* Court cards */
.court-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.court-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  text-decoration: none;
  color: inherit;
  display: flex;
  gap: 16px;
  align-items: stretch;
  transition: box-shadow 0.15s, transform 0.1s;
  border-left: 4px solid var(--green-600);
}

.court-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.court-card-left {
  flex: 1;
  min-width: 0;
}

.court-card-right {
  flex: 0 0 280px;
  border-left: 1px solid var(--gray-100);
  padding-left: 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  font-size: 0.8125rem;
  color: var(--gray-500);
}

.court-card-right .latest-label {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-400);
  margin-bottom: 4px;
  font-weight: 600;
}

.court-card-right .latest-comment {
  color: var(--gray-600);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 4px;
}

.court-card-right .no-reports {
  background: none;
  box-shadow: none;
  padding: 0;
  text-align: left;
  font-size: 0.8125rem;
  color: var(--gray-400);
  font-style: italic;
}

.court-card-name {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--green-800);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Spinning tennis ball "Just Reviewed" badge */
.just-reviewed {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%);
  border: 1.5px solid var(--green-400);
  color: var(--green-800);
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 9px 2px 6px;
  border-radius: 99px;
  white-space: nowrap;
  animation: badge-pop 0.4s ease-out;
}

.just-reviewed .tennis-ball {
  display: inline-block;
  width: 16px;
  height: 16px;
  line-height: 16px;
  text-align: center;
  font-size: 14px;
  animation: spin-ball 2s linear infinite;
  flex-shrink: 0;
}

@keyframes spin-ball {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes badge-pop {
  0% { transform: scale(0.7); opacity: 0; }
  60% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

/* Photo thumbnail in latest report */
.court-card-right-content {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.latest-photo-thumb {
  width: 52px;
  height: 52px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--gray-200);
  flex-shrink: 0;
}

.latest-report-text {
  flex: 1;
  min-width: 0;
}

.court-card-location {
  font-size: 0.875rem;
  color: var(--gray-500);
  margin-bottom: 8px;
}

.court-card-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

@media (max-width: 639px) {
  .court-card {
    flex-direction: column;
  }
  .court-card-right {
    flex: none;
    border-left: none;
    padding-left: 0;
    border-top: 1px solid var(--gray-100);
    padding-top: 8px;
  }
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-surface {
  background: var(--green-100);
  color: var(--green-800);
}

.badge-access {
  background: var(--gray-100);
  color: var(--gray-600);
}

.badge-lights {
  background: #fef9c3;
  color: #a16207;
}

.court-card-status {
  font-size: 0.8125rem;
  color: var(--gray-500);
  border-top: 1px solid var(--gray-100);
  padding-top: 8px;
  margin-top: 4px;
}

.court-card-status strong {
  color: var(--gray-700);
}

/* Status colors */
.status-great { color: var(--green-700); }
.status-wet { color: var(--blue-500); }
.status-cracked { color: var(--orange-500); }
.status-busy { color: var(--yellow-500); }
.status-closed { color: var(--red-500); }

.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 0.8125rem;
  font-weight: 600;
}

.status-badge-great { background: var(--green-100); color: var(--green-700); }
.status-badge-wet { background: #dbeafe; color: #1d4ed8; }
.status-badge-cracked { background: #ffedd5; color: #c2410c; }
.status-badge-busy { background: var(--yellow-100); color: #a16207; }
.status-badge-closed { background: var(--red-100); color: #b91c1c; }

/* Court detail */
.court-detail-header {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.court-detail-header h2 {
  font-size: 1.375rem;
  color: var(--green-900);
  margin-bottom: 4px;
}

.court-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}

.court-info-item {
  font-size: 0.875rem;
}

.court-info-item .label {
  color: var(--gray-400);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}

.court-info-item .value {
  color: var(--gray-800);
  font-weight: 500;
}

.maps-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 12px;
  font-size: 0.875rem;
  color: var(--green-700);
  text-decoration: none;
  font-weight: 500;
}

.maps-link:hover { text-decoration: underline; }

/* Report form */
.report-form-section {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.report-form-section h3 {
  font-size: 1.0625rem;
  color: var(--green-800);
  margin-bottom: 12px;
}

/* Forms */
.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 4px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 0.9375rem;
  font-family: inherit;
  transition: border-color 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--green-500);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15);
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Status radio group */
.status-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.status-option {
  position: relative;
}

.status-option input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.status-option label {
  display: inline-block;
  padding: 8px 14px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}

.status-option input:checked + label {
  border-color: var(--green-600);
  background: var(--green-50);
  color: var(--green-800);
}

.status-option label:hover {
  border-color: var(--green-400);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  font-family: inherit;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--green-600);
  color: white;
  width: 100%;
}

.btn-primary:hover { background: var(--green-700); }

.btn-small {
  padding: 5px 10px;
  font-size: 0.75rem;
}

.btn-flag {
  background: none;
  border: 1px solid var(--gray-300);
  color: var(--gray-500);
  padding: 4px 10px;
  font-size: 0.75rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
}

.btn-flag:hover {
  border-color: var(--red-500);
  color: var(--red-500);
}

.btn-flag.flagged {
  border-color: var(--red-500);
  color: var(--red-500);
}

/* Reports list */
.reports-section h3 {
  font-size: 1.0625rem;
  color: var(--green-800);
  margin-bottom: 12px;
}

.report-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 12px;
  border-left: 4px solid var(--green-500);
}

.report-card.stale {
  opacity: 0.5;
  border-left-color: var(--gray-300);
}

.report-card.stale .report-stale-notice {
  display: block;
}

.report-stale-notice {
  display: none;
  font-size: 0.75rem;
  color: var(--gray-400);
  font-style: italic;
  margin-bottom: 6px;
}

.report-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  flex-wrap: wrap;
  gap: 6px;
}

.report-timestamp {
  font-size: 0.8125rem;
  color: var(--gray-400);
}

.report-timestamp .time-ago {
  font-weight: 600;
  color: var(--gray-600);
}

.report-comment {
  font-size: 0.9375rem;
  color: var(--gray-700);
  margin-bottom: 10px;
  line-height: 1.5;
}

.report-photos {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.report-photos img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 6px;
  cursor: pointer;
  transition: transform 0.15s;
  border: 1px solid var(--gray-200);
}

.report-photos img:hover {
  transform: scale(1.05);
}

.report-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 8px;
  border-top: 1px solid var(--gray-100);
}

.flag-warning {
  display: inline-block;
  background: var(--yellow-100);
  color: #92400e;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
}

/* File input */
.file-input-wrapper {
  position: relative;
}

.file-input-wrapper input[type="file"] {
  font-size: 0.875rem;
  padding: 8px;
}

/* Add court page */
.add-court-form {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--gray-400);
}

.empty-state p {
  font-size: 1.0625rem;
  margin-bottom: 16px;
}

/* Lightbox */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 200;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.lightbox.active {
  display: flex;
}

.lightbox img {
  max-width: 95vw;
  max-height: 90vh;
  border-radius: var(--radius);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--gray-800);
  color: white;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  z-index: 300;
  transition: transform 0.3s ease;
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

/* Loading */
.loading {
  text-align: center;
  padding: 32px;
  color: var(--gray-400);
}

/* No reports */
.no-reports {
  text-align: center;
  padding: 24px;
  color: var(--gray-400);
  font-size: 0.9375rem;
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* Responsive */
@media (min-width: 640px) {
  .container { padding: 24px; }
  .court-info-grid { grid-template-columns: 1fr 1fr 1fr 1fr; }
  .report-photos img { width: 100px; height: 100px; }
}
