/* Modern CSS Variables & Reset */
:root {
  /* Colors */
  --primary-50: #eff6ff;
  --primary-100: #dbeafe;
  --primary-500: #3b82f6;
  --primary-600: #2563eb;
  --primary-700: #1d4ed8;
  --primary-900: #1e3a8a;

  --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;

  --orange-400: #fb923c;
  --orange-500: #f97316;
  --red-500: #ef4444;
  --red-600: #dc2626;
  --green-500: #10b981;
  --green-600: #059669;

  /* Gradients */
  --gradient-bg: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --gradient-card: linear-gradient(145deg, #ffffff 0%, #f8fafc 100%);
  --gradient-map: linear-gradient(135deg, #b4d2ff 0%, #f0f9ff 100%);

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1),
    0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1),
    0 8px 10px -6px rgb(0 0 0 / 0.1);

  /* Typography */
  --font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-12: 3rem;
  --space-16: 4rem;

  /* Border Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-2xl: 1.5rem;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 300ms ease;
  --transition-slow: 500ms ease;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-family);
  font-weight: 400;
  line-height: 1.6;
  color: var(--gray-900);
  background: var(--gradient-bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Loading Screen */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity var(--transition-slow), visibility var(--transition-slow);
}

.loading-overlay.loaded {
  opacity: 0;
  visibility: hidden;
}

.loading-content {
  text-align: center;
  color: white;
}

.loading-spinner {
  width: 60px;
  height: 60px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top: 4px solid white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto var(--space-6);
}

.loading-text h3 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: var(--space-2);
}

.loading-text p {
  font-size: 1rem;
  opacity: 0.8;
}

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

/* App Container */
.app-container {
  max-width: 1440px;
  margin: 0 auto;
  padding: var(--space-6);
  min-height: 100vh;
}

/* Header */
.app-header {
  margin-bottom: var(--space-8);
}

.header-content {
  background: var(--gradient-card);
  border-radius: var(--radius-2xl);
  padding: var(--space-8);
  box-shadow: var(--shadow-xl);
  border: 1px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-6);
}

.header-main {
  flex: 1;
}

.app-title {
  font-size: 3rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary-600), var(--primary-900));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: var(--space-2);
  line-height: 1.2;
}

.app-subtitle {
  font-size: 1.2rem;
  color: var(--gray-600);
  font-weight: 500;
  max-width: 600px;
}

.pc-notice {
  font-size: 0.95rem;
  color: #dc2626;
  font-weight: 600;
  margin-top: var(--space-3);
  padding: var(--space-2) var(--space-4);
  background: #fef2f2;
  border-left: 3px solid #ef4444;
  border-radius: var(--radius-sm);
  display: inline-block;
}

.header-badge {
  flex-shrink: 0;
}

.badge {
  display: inline-block;
  background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
  color: white;
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-xl);
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: var(--shadow-md);
}

/* Main Content */
.main-content {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-8);
}

/* Map Section */
.map-section {
  background: var(--gradient-card);
  border-radius: var(--radius-2xl);
  padding: var(--space-8);
  box-shadow: var(--shadow-xl);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.map-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
  gap: var(--space-4);
}

.section-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--gray-800);
}

.map-legend {
  display: flex;
  gap: var(--space-6);
  align-items: center;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.9rem;
  color: var(--gray-600);
  font-weight: 500;
}

.legend-circle {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-normal {
  background: var(--orange-500);
}

.legend-major {
  background: var(--red-600);
}

.map-container {
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--gray-200);
}

.map-canvas {
  width: 100%;
  height: 600px;
  background: var(--gradient-map);
  position: relative;
}

/* Controls Section - Now integrated into map section */
.map-controls {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
}

/* Year Selector - Modern Design */
.year-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: var(--space-3);
}

.year-btn {
  background: linear-gradient(145deg, #ffffff, #f8fafc);
  border: 1px solid rgba(229, 231, 235, 0.6);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gray-700);
  cursor: pointer;
  transition: all var(--transition-normal);
  text-align: center;
  position: relative;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08),
    0 0 0 1px rgba(255, 255, 255, 0.9) inset;
  backdrop-filter: blur(20px);
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.year-btn::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(59, 130, 246, 0.15),
    transparent
  );
  opacity: 0;
  transition: all var(--transition-normal);
}

.year-btn:hover {
  border-color: rgba(59, 130, 246, 0.4);
  color: var(--primary-700);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2),
    0 0 0 1px rgba(255, 255, 255, 1) inset;
}

.year-btn:hover::before {
  opacity: 1;
  left: 100%;
}

.year-btn.active {
  background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
  border-color: var(--primary-600);
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.35),
    0 0 0 1px rgba(255, 255, 255, 0.2) inset;
}

.year-btn.active::before {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0),
    rgba(255, 255, 255, 0.3),
    rgba(255, 255, 255, 0)
  );
  opacity: 1;
  left: 100%;
}

.year-btn:active {
  transform: translateY(-1px);
  transition: transform 0.1s ease;
}

/* SVG Styles */
.map-japan {
  fill: var(--green-500);
  stroke: rgb(68, 109, 40);
  stroke-width: 0.1px;
  stroke-linejoin: round;
  transition: fill var(--transition-fast);
}

.earthquake-circle {
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
  stroke: none !important;
  stroke-width: 0 !important;
}

.earthquake-ripple {
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.15));
  pointer-events: none;
}

.eq-info-text,
.eq-history-text {
  font-family: var(--font-family);
  font-weight: 500;
}

.eq-info-text {
  font-size: 14px;
  fill: var(--gray-600);
}

.eq-history-text {
  font-size: 12px;
  fill: var(--gray-700);
}

/* Responsive Design */
@media (max-width: 1024px) {
  .app-container {
    padding: var(--space-4);
  }

  .header-content {
    flex-direction: column;
    text-align: center;
  }

  .app-title {
    font-size: 2.5rem;
  }

  .map-canvas {
    height: 500px;
  }
}

@media (max-width: 768px) {
  .app-container {
    padding: var(--space-3);
  }

  .header-content,
  .map-section {
    padding: var(--space-6);
  }

  .app-title {
    font-size: 2rem;
  }

  .app-subtitle {
    font-size: 1rem;
  }

  .pc-notice {
    font-size: 0.85rem;
    margin-top: var(--space-2);
  }

  .map-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .map-legend {
    justify-content: center;
    width: 100%;
  }

  .map-canvas {
    height: 400px;
  }

  .year-grid {
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: var(--space-2);
  }

  .year-btn {
    padding: var(--space-2) var(--space-2);
    font-size: 0.8rem;
    min-height: 32px;
  }

  .map-controls {
    margin-top: var(--space-3);
    padding-top: var(--space-3);
  }
}

@media (max-width: 480px) {
  .app-title {
    font-size: 1.8rem;
  }

  .map-canvas {
    height: 350px;
  }

  .year-grid {
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
  }
}