html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  background: #050812;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  cursor: default;
}

#map {
  width: 100vw;
  height: 100vh;
  position: relative;
  background: #020818;
  cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M3 3 L11 11 L8 11 L12 21 L13 21 L9 11 L12 11 Z" fill="white" stroke="black" stroke-width="1.5"/></svg>') 3 3, auto;
}

.logo-header {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 2001;
  background: none;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo-icon {
  width: 100px;
  height: 100px;
  flex-shrink: 0;
}

.logo-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.logo-title {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: 1.5px;
  color: #00eaff;
  opacity: 0.85;
  margin: 0;
  text-shadow: 0 0 12px rgba(0, 234, 255, 0.8);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  text-transform: uppercase;
}

.logo-subtitle {
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 1px;
  color: #00eaff;
  opacity: 0.77;
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  text-transform: uppercase;
}

.version {
  font-size: 10px;
  font-weight: 300;
  letter-spacing: 0.5px;
  color: #00eaff;
  opacity: 0.5;
  margin: 2px 0 0 0;
  font-family: 'Courier New', monospace;
}

#radar-sweep {
  animation: radar-spin 4s linear infinite;
  transform-origin: 90px 90px;
  will-change: transform; /* Optimize for mobile - prevents repaints */
  backface-visibility: hidden; /* Reduces jitter on mobile */
  -webkit-backface-visibility: hidden; /* Safari/iOS support */
}

@keyframes radar-spin {
  from {
    transform: rotate(0deg) translateZ(0); /* Force GPU acceleration */
  }
  to {
    transform: rotate(360deg) translateZ(0);
  }
}

.vessel-svg-icon {
  background: none !important;
  border: none !important;
}

.attribution {
  position: fixed;
  bottom: 4px;
  left: 4px;
  background: #111;
  padding: 5px 10px;
  font-size: 12px;
  color: #bbb;
  opacity: 0.93;
  border-radius: 5px;
  z-index: 2000;
  pointer-events: auto;
  font-weight: 400;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
}

.license-link {
  color: #00eaff;
  text-decoration: none;
  font-weight: 500;
  cursor: pointer;
}

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

.license-modal {
  position: fixed;
  z-index: 3000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
}

.license-modal-content {
  background: rgba(5, 8, 18, 0.98);
  padding: 24px 30px;
  border: 1px solid rgba(0, 234, 255, 0.3);
  border-radius: 8px;
  max-width: 500px;
  width: 90%;
  color: #eee;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  position: relative;
}

.license-modal-content h3 {
  margin: 0 0 16px 0;
  color: #00eaff;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.license-section {
  margin-bottom: 14px;
  line-height: 1.5;
  font-size: 13px;
}

.license-section strong {
  color: #00eaff;
  font-weight: 600;
}

.license-section a {
  color: #aaa;
  text-decoration: underline;
}

.license-section a:hover {
  color: #00eaff;
}

.license-close {
  position: absolute;
  right: 16px;
  top: 16px;
  color: #bbb;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  line-height: 1;
  transition: color 0.2s;
}

.license-close:hover,
.license-close:focus {
  color: #00eaff;
}

.flag-img {
  width: 24px;
  height: 18px;
  vertical-align: middle;
  margin-left: 4px;
  border: 1px solid #ccc;
  border-radius: 3px;
  background: #eee;
}

.sky-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 35vh;
  pointer-events: none;
  z-index: 1500;
  background: linear-gradient(
    to bottom,
    rgba(5, 8, 18, 0.85),
    rgba(5, 8, 18, 0)
  );
}

.ground-vignette {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100vw;
  height: 25vh;
  pointer-events: none;
  z-index: 1500;
  background: radial-gradient(
    ellipse at bottom,
    rgba(0, 0, 0, 0.6),
    transparent 60%
  );
}

.stats-panel {
  position: fixed;
  right: 0;
  bottom: 60px;
  z-index: 2001;
  background: rgba(5, 8, 18, 0.96);
  color: #eee;
  padding: 8px 12px;
  border-radius: 6px 0 0 6px;
  font-size: 13px;
  width: 340px;
  box-shadow: -2px 2px 10px rgba(0,0,0,0.4);
  border: 1px solid rgba(0, 234, 255, 0.2);
  border-right: none;
  transition: all 0.3s ease;
  transform: translateX(0);
}

.stats-header {
  font-weight: 600;
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: #00eaff;
  margin-bottom: 4px;
  opacity: 0.9;
  text-shadow: 0 0 12px rgba(0, 234, 255, 0.8);
  user-select: none;
  cursor: pointer;
  outline: none;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}

.stats-header-title {
  flex: 1;
}

.clear-filter-btn {
  background: rgba(255, 0, 0, 0.2);
  border: 1px solid rgba(255, 0, 0, 0.4);
  color: #ff6b6b;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  line-height: 1;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.clear-filter-btn:hover {
  background: rgba(255, 0, 0, 0.3);
  border-color: #ff6b6b;
  transform: scale(1.1);
}

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

.stats-summary {
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(0, 234, 255, 0.2);
  font-size: 13px;
}

.stats-summary strong {
  font-weight: 600;
  color: #00eaff;
}

.stats-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(0, 234, 255, 0.2);
}

.stats-tab {
  flex: 1;
  padding: 6px 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  background: rgba(0, 234, 255, 0.05);
  color: #888;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.stats-tab:hover {
  background: rgba(0, 234, 255, 0.1);
  color: #00eaff;
}

.stats-tab.active {
  background: rgba(0, 234, 255, 0.15);
  color: #00eaff;
  border-bottom-color: #00eaff;
}

.stats-tab-content {
  min-height: 100px;
  max-height: 220px;
}

.stats-scrollable {
  max-height: 220px;
  overflow-y: auto;
  font-size: 12px;
  padding-right: 4px;
}

.stats-scrollable::-webkit-scrollbar {
  width: 6px;
}

.stats-scrollable::-webkit-scrollbar-track {
  background: rgba(0, 234, 255, 0.05);
  border-radius: 3px;
}

.stats-scrollable::-webkit-scrollbar-thumb {
  background: rgba(0, 234, 255, 0.3);
  border-radius: 3px;
}

.stats-scrollable::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 234, 255, 0.5);
}

.stats-dest-item {
  padding: 4px 0;
  line-height: 1.4;
  border-bottom: 1px solid rgba(0, 234, 255, 0.1);
}

.stats-dest-item:last-child {
  border-bottom: none;
}

.stats-count {
  color: #00eaff;
  font-weight: 600;
}

.stats-empty {
  padding: 20px;
  text-align: center;
  color: #666;
  font-size: 10px;
}

.stats-filter-label {
  display: block;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 98%;
}

.stats-filter-label input {
  margin-right: 4px;
  vertical-align: middle;
}

.stats-panel-collapsed #stats-content {
  display: none;
}

.stats-panel-collapsed {
  transform: translateX(calc(100% - 36px));
}

/* ============================================================
   DAILY REPORT PANEL (AI Summary)
   Positioned at top-right corner
   ============================================================ */

.report-panel {
  position: fixed;
  right: 0;
  top: 20px; /* Top-right corner */
  z-index: 2001;
  background: rgba(5, 8, 18, 0.96);
  color: #eee;
  padding: 8px 12px;
  border-radius: 6px 0 0 6px;
  font-size: 13px;
  width: 340px;
  max-height: 400px; /* Limit height for scrolling */
  overflow-y: auto; /* Scrollable content */
  box-shadow: -2px 2px 10px rgba(0,0,0,0.4);
  border: 1px solid rgba(0, 234, 255, 0.2);
  border-right: none;
  transition: all 0.3s ease;
  transform: translateX(0);
}

.report-panel-collapsed {
  transform: translateX(calc(100% - 36px));
  width: 40px;
  height: 200px;
  padding: 12px 8px;
  opacity: 0.85;
  display: flex;
  align-items: center;
  justify-content: center;
}

.report-panel-collapsed:hover {
  opacity: 1;
}

.report-panel-collapsed .report-header {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  margin-bottom: 0;
  border-bottom: none;
}

.report-panel-collapsed #report-content {
  display: none;
}

.report-header {
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.05em;
  color: #00eaff;
  margin-bottom: 8px;
  opacity: 0.9;
  text-shadow: 0 0 12px rgba(0, 234, 255, 0.8);
  user-select: none;
  cursor: pointer;
  outline: none;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(0, 234, 255, 0.2);
}

.report-header-title {
  flex: 1;
  font-size: 13px;
}

.report-body {
  font-size: 12px;
  line-height: 1.6;
  color: #ddd;
}

/* Report content styling */
.report-body h3 {
  font-size: 13px;
  color: #00eaff;
  margin: 12px 0 6px 0;
  font-weight: 600;
}

.report-body strong {
  color: #00eaff;
  font-weight: 600;
}

.report-body ul {
  margin: 6px 0;
  padding-left: 20px;
}

.report-body li {
  margin: 4px 0;
}

/* Russia-related highlighting */
.report-body .russia-alert {
  background: rgba(255, 0, 0, 0.1);
  border-left: 3px solid #ff4444;
  padding: 8px;
  margin: 8px 0;
  border-radius: 4px;
}

/* Loading state */
.report-body.loading {
  text-align: center;
  padding: 20px;
  color: #888;
}

/* Error state */
.report-body.error {
  color: #ff6b6b;
  padding: 12px;
  text-align: center;
}

/* Arrow rotation for collapse/expand */
#report-panel-arrow {
  transition: transform 0.3s ease;
  font-size: 12px;
  color: #00eaff;
  margin-left: 8px;
  vertical-align: middle;
  user-select: none;
}

.report-panel-collapsed #report-panel-arrow {
  transform: rotate(180deg);
}

.stats-panel-collapsed {
  width: 40px;
  height: 200px;
  padding: 12px 8px;
  border-radius: 6px 0 0 6px;
  bottom: 60px;
  opacity: 0.85;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stats-panel-collapsed:hover {
  opacity: 1;
}

.stats-panel-collapsed .stats-header {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  margin-bottom: 0;
}

.stats-panel-collapsed #stats-content {
  display: none;
}

.stats-panel #stats-panel-arrow {
  margin-left: 8px;
  font-size: 14px;
  transition: transform 0.2s;
  color: #00eaff;
  vertical-align: middle;
  user-select: none;
}

/* Vessel popup styling */
.maplibregl-popup {
  z-index: 9999 !important;
  pointer-events: none;
}

.maplibregl-popup-content {
  background: rgba(15, 15, 20, 0.95);
  color: #e0e0e0;
  border: 1px solid rgba(0, 234, 255, 0.3);
  border-radius: 4px;
  padding: 0;
  font-size: 11px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  max-width: 280px;
  pointer-events: auto;
}

.maplibregl-popup-close-button {
  color: #00eaff;
  font-size: 18px;
  padding: 4px 8px;
  opacity: 0.7;
}

.maplibregl-popup-close-button:hover {
  background: rgba(0, 234, 255, 0.1);
  opacity: 1;
}

.maplibregl-popup-tip {
  border-top-color: rgba(15, 15, 20, 0.95);
}

.vessel-popup {
  padding: 10px;
}

.popup-header {
  border-bottom: 1px solid rgba(0, 234, 255, 0.2);
  padding-bottom: 6px;
  margin-bottom: 8px;
}

.popup-title {
  font-size: 16px;
  font-weight: 600;
  color: #00eaff;
  margin-bottom: 2px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.popup-subtitle {
  font-size: 12px;
  color: #888;
  text-transform: uppercase;
}

.popup-section {
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.popup-section:last-of-type {
  border-bottom: none;
  margin-bottom: 6px;
}

.popup-scrollable {
  max-height: 200px;
  overflow-y: auto;
  overflow-x: hidden;
}

.popup-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 1px 0;
  line-height: 1.3;
}

.popup-row .label {
  color: #888;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  min-width: 45px;
}

.popup-row .value {
  color: #e0e0e0;
  font-size: 13px;
  text-align: right;
  flex: 1;
  font-family: 'Courier New', monospace;
}

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

.status-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 4px;
}

.popup-details {
  margin-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding-top: 6px;
}

.popup-details-toggle {
  cursor: pointer;
  font-size: 10px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 4px 0;
  user-select: none;
  list-style: none;
}

.popup-details-toggle::-webkit-details-marker {
  display: none;
}

.popup-details-toggle::before {
  content: "▸ ";
  color: #00eaff;
  margin-right: 4px;
}

.popup-details[open] .popup-details-toggle::before {
  content: "▾ ";
}

.popup-details-toggle:hover {
  color: #00eaff;
}

.popup-details-content {
  margin-top: 4px;
  border-top: none;
  padding-top: 0;
}

.popup-track-btn {
  width: 100%;
  padding: 8px;
  background: rgba(0, 234, 255, 0.1);
  border: 1px solid rgba(0, 234, 255, 0.3);
  border-radius: 3px;
  color: #00eaff;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.popup-track-btn:hover {
  background: rgba(0, 234, 255, 0.2);
  border-color: #00eaff;
  box-shadow: 0 0 8px rgba(0, 234, 255, 0.3);
}

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

.track-icon {
  font-size: 14px;
  opacity: 0.8;
}

/* Historical marker */
.historical-marker {
  cursor: pointer;
}

.historical-marker:hover svg {
  filter: brightness(1.3);
}

/* Restore view hint */
#restore-hint {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3000;
  background: rgba(0, 234, 255, 0.95);
  color: #000;
  padding: 10px 16px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  display: none;
  align-items: center;
  gap: 12px;
  box-shadow: 0 4px 12px rgba(0, 234, 255, 0.5);
  animation: hint-pulse 2s ease-in-out infinite;
}

#restore-hint button {
  background: none;
  border: none;
  color: #000;
  font-size: 20px;
  font-weight: bold;
  cursor: pointer;
  padding: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
}

#restore-hint button:hover {
  opacity: 1;
}

@keyframes hint-pulse {
  0%, 100% { 
    box-shadow: 0 4px 12px rgba(0, 234, 255, 0.5);
  }
  50% { 
    box-shadow: 0 4px 20px rgba(0, 234, 255, 0.8);
  }
}

/* ============================================================================
   Buoy Markers
   ============================================================================ */

.buoy-marker {
  filter: drop-shadow(0 0 4px rgba(0, 234, 255, 0.6));
}

.buoy-marker:hover {
  transform: scale(1.2);
  filter: drop-shadow(0 0 8px rgba(0, 234, 255, 0.9));
  transition: transform 0.2s ease, filter 0.2s ease;
}

.buoy-popup {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  max-width: 280px;
  padding: 10px;
}

.buoy-popup .popup-header {
  border-bottom: 1px solid rgba(0, 234, 255, 0.2);
  padding-bottom: 6px;
  margin-bottom: 8px;
  font-size: 16px;
  font-weight: 600;
  color: #00eaff;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.buoy-popup .popup-section {
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.buoy-popup .popup-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 1px 0;
  line-height: 1.3;
}

.buoy-popup .popup-row .label {
  color: #888;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  min-width: 45px;
}

.buoy-popup .popup-row .value {
  color: #e0e0e0;
  font-size: 13px;
  text-align: right;
  flex: 1;
  font-family: 'Courier New', monospace;
}

.buoy-popup .popup-footer {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid rgba(0, 234, 255, 0.2);
  text-align: right;
}

.buoy-popup .popup-footer small {
  color: rgba(255, 255, 255, 0.5);
  font-size: 11px;
}

/* Install Button */
.install-button {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2002;
  width: 48px;
  height: 48px;
  background: rgba(0, 234, 255, 0.15);
  backdrop-filter: blur(10px);
  border: 2px solid #00eaff;
  border-radius: 12px;
  color: #00eaff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 234, 255, 0.3);
}

.install-button:hover {
  background: rgba(0, 234, 255, 0.25);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 234, 255, 0.5);
}

.install-button:active {
  transform: translateY(0);
}

.install-button svg {
  width: 24px;
  height: 24px;
}

/* Install Banner */
.install-banner {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2002;
  background: rgba(5, 8, 18, 0.95);
  backdrop-filter: blur(20px);
  border: 2px solid #00eaff;
  border-radius: 16px;
  padding: 16px 20px;
  box-shadow: 0 8px 32px rgba(0, 234, 255, 0.4);
  max-width: 90%;
  width: 420px;
  animation: slideUp 0.5s ease-out;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.install-banner-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.install-banner-icon {
  font-size: 32px;
  flex-shrink: 0;
}

.install-banner-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.install-banner-text strong {
  color: #00eaff;
  font-size: 16px;
  font-weight: 600;
}

.install-banner-text small {
  color: rgba(0, 234, 255, 0.7);
  font-size: 13px;
}

.install-banner-action {
  background: #00eaff;
  color: #050812;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.install-banner-action:hover {
  background: #00d4e6;
  transform: scale(1.05);
}

.install-banner-action:active {
  transform: scale(0.98);
}

.install-banner-close {
  background: transparent;
  border: none;
  color: rgba(0, 234, 255, 0.6);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  transition: color 0.2s ease;
  flex-shrink: 0;
}

.install-banner-close:hover {
  color: #00eaff;
}

/* Mobile adjustments */
@media (max-width: 600px) {
  .install-button {
    width: 44px;
    height: 44px;
    top: 16px;
    right: 16px;
  }
  
  .install-banner {
    bottom: 16px;
    width: calc(100% - 32px);
    padding: 14px 16px;
  }
  
  .install-banner-icon {
    font-size: 28px;
  }
  
  .install-banner-text strong {
    font-size: 15px;
  }
  
  .install-banner-text small {
    font-size: 12px;
  }
  
  .install-banner-action {
    padding: 8px 16px;
    font-size: 13px;
  }
}

/* Hide install prompts when running as installed PWA */
@media (display-mode: standalone) {
  .install-button,
  .install-banner {
    display: none !important;
  }
}
