:root {
  --bg-primary: #424658;
  --font-color: #E0CDB2;
  --ocean-color: #2c6aa8;
  --land-color: #4cc88a;
  --border-color: #1a4d7a;
  --hover-color: #ea752c;
  --modal-bg: rgba(66, 70, 88, 0.75);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--font-color);
  display: flex;
  align-items: center;
  justify-content: center;
}

#app {
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 10px 20px 20px 20px;
  overflow: hidden;
  position: relative;
}

/* Language Selector */
.language-selector {
  position: absolute;
  top: 15px;
  right: 25px;
  display: flex;
  gap: 8px;
  z-index: 100;
}

.lang-btn {
  padding: 8px 16px;
  border: 2px solid var(--font-color);
  border-radius: 6px;
  background: transparent;
  color: var(--font-color);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.lang-btn:hover {
  background: var(--font-color);
  color: var(--bg-primary);
}

.lang-btn.active {
  background: var(--font-color);
  color: var(--bg-primary);
}

/* Layer Toggle Buttons */
.layer-toggles {
  position: absolute;
  top: 15px;
  left: 25px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
}

.toggle-btn {
  padding: 8px 16px;
  border: 2px solid var(--font-color);
  border-radius: 6px;
  background: transparent;
  color: var(--font-color);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 160px;
}

.toggle-btn:hover {
  background: rgba(224, 205, 178, 0.1);
  border-color: var(--hover-color);
}

.toggle-btn.active {
  background: var(--font-color);
  color: var(--bg-primary);
}

.toggle-icon {
  font-size: 1.1rem;
  font-weight: bold;
}

.app-title {
  font-size: 2.5rem;
  font-weight: bold;
  margin-bottom: 10px;
  text-align: center;
  color: var(--font-color);
  position: relative;
  z-index: 10;
}

.app-title a {
  margin-left: 0.5rem;
  font-family: sans-serif;
  font-size: 0.5em;
  font-style: italic;
  text-decoration: underline;
  color: var(--font-color);
  transition: color 0.3s ease;
}

.app-title a:hover {
  color: rgb(0, 51, 255);
}

.instruction {
  font-size: 1rem;
  margin-bottom: 15px;
  text-align: center;
  color: var(--font-color);
  opacity: 0.8;
  position: relative;
  z-index: 10;
}

/* Search Container */
.search-container {
  display: flex;
  gap: 8px;
  margin-bottom: 15px;
  max-width: 400px;
  width: 100%;
  z-index: 10;
  position: relative;
  flex-wrap: wrap;
}

#country-search {
  flex: 1;
  padding: 10px 15px;
  border: 2px solid var(--font-color);
  border-radius: 6px;
  background: var(--bg-primary);
  color: var(--font-color);
  font-size: 0.95rem;
  font-family: var(--font-sans);
  outline: none;
  transition: all 0.3s ease;
}

#country-search::placeholder {
  color: var(--font-color);
  opacity: 0.6;
}

#country-search:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(129, 163, 198, 0.2);
}

#search-btn {
  padding: 10px 20px;
  border: 2px solid var(--font-color);
  border-radius: 6px;
  background: var(--font-color);
  color: var(--bg-primary);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  white-space: nowrap;
}

#search-btn:hover {
  background: transparent;
  color: var(--font-color);
}

/* Search Autocomplete Dropdown */
.search-results-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 110px;
  max-height: 300px;
  overflow-y: auto;
  background: var(--bg-primary);
  border: 2px solid var(--font-color);
  border-top: none;
  border-radius: 0 0 6px 6px;
  z-index: 1000;
  display: none;
  margin-top: -2px;
}

.search-results-dropdown.show {
  display: block;
}

.search-result-item {
  padding: 12px 15px;
  cursor: pointer;
  color: var(--font-color);
  font-size: 0.9rem;
  border-bottom: 1px solid rgba(224, 205, 178, 0.2);
  transition: background 0.2s ease;
}

.search-result-item:hover {
  background: rgba(224, 205, 178, 0.15);
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-status {
  position: absolute;
  top: 100%;
  left: 0;
  right: 110px;
  padding: 12px 15px;
  text-align: center;
  color: var(--font-color);
  font-size: 0.85rem;
  font-style: italic;
  background: var(--bg-primary);
  border: 2px solid var(--font-color);
  border-top: none;
  border-radius: 0 0 6px 6px;
  margin-top: -2px;
  display: none;
}

.search-status.show {
  display: block;
}

.search-status.loading {
  color: var(--accent-primary);
}

.search-status.error {
  color: #e74c3c;
}

.search-status.no-results {
  opacity: 0.7;
}

#globe-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 100%;
  position: relative;
  min-height: 0;
  overflow: visible;
  padding-bottom: 20px;
  touch-action: none;
}

#globe {
  width: 100%;
  height: 100%;
  max-width: 900px;
  max-height: 900px;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#globe:active {
  cursor: grabbing;
}

/* Globe styles */
.sphere {
  fill: var(--ocean-color);
  stroke: var(--border-color);
  stroke-width: 1.5px;
}

.country {
  fill: var(--land-color);
  stroke: var(--border-color);
  stroke-width: 0.5px;
  cursor: pointer;
  transition: fill 0.2s ease;
}

.country:hover {
  fill: var(--hover-color);
  stroke-width: 1px;
}

.country.selected {
  fill: var(--hover-color);
  stroke-width: 1.5px;
}

/* Modal styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  transition: opacity 0.3s ease;
}

.modal.hidden {
  display: none;
  opacity: 0;
}

.modal-content {
  background: var(--modal-bg);
  border: 2px solid var(--font-color);
  border-radius: 12px;
  padding: 30px;
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.modal-close {
  position: absolute;
  top: 15px;
  right: 20px;
  background: transparent;
  border: none;
  font-size: 2rem;
  color: var(--font-color);
  cursor: pointer;
  line-height: 1;
  transition: color 0.2s ease;
}

.modal-close:hover {
  color: var(--hover-color);
}

#country-name {
  font-size: 2rem;
  margin-bottom: 20px;
  color: var(--font-color);
  padding-right: 30px;
}

#country-info {
  color: var(--font-color);
  line-height: 1.8;
}

#country-info p {
  margin-bottom: 10px;
}

#country-info .info-label {
  font-weight: bold;
  color: var(--hover-color);
}

.info-placeholder {
  font-style: italic;
  opacity: 0.7;
}

/* Responsive design */
@media (max-width: 768px) {
  #app {
    padding: 10px;
  }

  /* Remove absolute positioning for mobile - make everything flow */
  .layer-toggles {
    position: static;
    flex-direction: row;
    width: 100%;
    justify-content: center;
    gap: 6px;
    margin-bottom: 8px;
    flex-wrap: wrap;
  }

  .toggle-btn {
    font-size: 0.75rem;
    padding: 6px 10px;
    min-width: 45%;
    flex: 1;
  }

  .toggle-icon {
    font-size: 0.9rem;
  }

  /* Remove absolute positioning for language selector on mobile */
  .language-selector {
    position: static;
    justify-content: flex-end;
    width: 100%;
    margin-bottom: 8px;
  }

  .lang-btn {
    padding: 6px 12px;
    font-size: 0.85rem;
  }

  .app-title {
    font-size: 1.3rem;
    margin-bottom: 8px;
    text-align: center;
    line-height: 1.3;
  }

  .app-title a {
    font-size: 0.4em;
    display: block;
    margin-top: 2px;
    margin-left: 0;
  }

  .instruction {
    font-size: 0.8rem;
    margin-bottom: 8px;
    display: none;
  }

  .search-container {
    margin-bottom: 10px;
  }

  #globe {
    max-width: 600px;
    max-height: 600px;
  }

  .modal-content {
    padding: 20px;
    max-width: 90%;
  }

  #country-name {
    font-size: 1.5rem;
    margin-bottom: 15px;
  }
}

@media (max-width: 480px) {
  #app {
    padding: 8px;
  }

  /* Further adjustments for very small screens */
  .layer-toggles {
    gap: 4px;
    margin-bottom: 5px;
    flex-direction: column;
  }

  .toggle-btn {
    font-size: 0.7rem;
    padding: 5px 8px;
    min-width: 100%;
    width: 100%;
  }

  .toggle-icon {
    font-size: 0.85rem;
  }

  .language-selector {
    margin-bottom: 6px;
  }

  .lang-btn {
    padding: 5px 10px;
    font-size: 0.8rem;
  }

  .app-title {
    font-size: 1rem;
    margin-bottom: 4px;
    line-height: 1.2;
  }

  .app-title a {
    font-size: 0.35em;
    display: block;
    margin-top: 1px;
    margin-left: 0;
  }

  .instruction {
    font-size: 0.7rem;
    margin-bottom: 6px;
    display: none;
  }

  .search-container {
    margin-bottom: 8px;
  }

  #country-search {
    padding: 6px 10px;
    font-size: 0.8rem;
  }

  #search-btn {
    padding: 6px 12px;
    font-size: 0.8rem;
  }

  #globe {
    max-width: 400px;
    max-height: 400px;
  }

  .modal-content {
    padding: 15px;
  }

  #country-name {
    font-size: 1.3rem;
    margin-bottom: 12px;
  }

  .modal-close {
    font-size: 1.5rem;
    top: 10px;
    right: 15px;
  }
}

/* Extra small mobile devices (360px and below) */
@media (max-width: 360px) {
  #app {
    padding: 5px;
  }

  .app-title {
    font-size: 0.9rem;
    margin-bottom: 3px;
  }

  .app-title a {
    font-size: 0.3em;
  }

  .language-selector {
    margin-bottom: 4px;
  }

  .lang-btn {
    padding: 4px 8px;
    font-size: 0.7rem;
  }

  .layer-toggles {
    gap: 3px;
    margin-bottom: 3px;
    flex-direction: column;
  }

  .toggle-btn {
    font-size: 0.65rem;
    padding: 4px 6px;
    width: 100%;
  }

  .toggle-icon {
    font-size: 0.75rem;
  }

  .search-container {
    margin-bottom: 6px;
  }

  #country-search {
    padding: 5px 8px;
    font-size: 0.75rem;
  }

  #search-btn {
    padding: 5px 10px;
    font-size: 0.75rem;
  }
}

/* Scrollbar styling for modal */
.modal-content::-webkit-scrollbar {
  width: 8px;
}

.modal-content::-webkit-scrollbar-track {
  background: rgba(224, 205, 178, 0.1);
  border-radius: 4px;
}

.modal-content::-webkit-scrollbar-thumb {
  background: var(--font-color);
  border-radius: 4px;
}

.modal-content::-webkit-scrollbar-thumb:hover {
  background: var(--hover-color);
}

/* Cities and Water Bodies Styles */
.city {
  fill: #FFD700;
  stroke: #000;
  stroke-width: 0.8px;
  cursor: pointer;
  transition: fill 0.2s ease;
  pointer-events: auto;
}

.city:hover {
  fill: #FFA500;
  stroke-width: 1.2px;
}

.city-label {
  fill: var(--font-color);
  font-size: 10px;
  font-weight: 600;
  pointer-events: none;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
}

.river {
  fill: none;
  stroke: #4A90E2;
  stroke-width: 2.5px;
  stroke-linecap: round;
  cursor: pointer;
  transition: all 0.2s ease;
}

.river:hover {
  stroke: #FFD700;
  stroke-width: 3.5px;
}

.lake {
  fill: #4A90E2;
  stroke: #2c6aa8;
  stroke-width: 0.5px;
  cursor: pointer;
  transition: all 0.2s ease;
  opacity: 0.8;
}

.lake:hover {
  fill: #FFD700;
  opacity: 1;
}

.water-label {
  fill: #E0F2F7;
  font-size: 9px;
  font-style: italic;
  pointer-events: none;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.9);
}

/* Marine Areas Styles */
.marine-area {
  cursor: default;
  transition: all 0.2s ease;
  pointer-events: none;
  fill: none;
}

.marine-ocean {
  stroke: #1a5c8a;
  stroke-width: 2px;
  stroke-dasharray: 4, 4;
  opacity: 0.4;
}

.marine-ocean:hover {
  fill: rgba(74, 144, 226, 0.15);
  stroke: #FFD700;
  stroke-width: 3px;
  stroke-dasharray: none;
  opacity: 1;
}

.marine-sea {
  stroke: #3a7dc0;
  stroke-width: 2px;
  opacity: 0.5;
}

.marine-sea:hover {
  fill: rgba(74, 144, 226, 0.2);
  stroke: #FFD700;
  stroke-width: 3px;
  opacity: 1;
}

.marine-bay {
  stroke: #4a8dd1;
  stroke-width: 1.5px;
  opacity: 0.5;
}

.marine-bay:hover {
  fill: rgba(74, 144, 226, 0.2);
  stroke: #FFD700;
  stroke-width: 2.5px;
  opacity: 1;
}

.marine-gulf {
  stroke: #5a9de2;
  stroke-width: 1.5px;
  opacity: 0.5;
}

.marine-gulf:hover {
  fill: rgba(74, 144, 226, 0.2);
  stroke: #FFD700;
  stroke-width: 2.5px;
  opacity: 1;
}

.marine-strait,
.marine-channel,
.marine-sound {
  stroke: #6aadf3;
  stroke-width: 1px;
  opacity: 0.4;
}

.marine-strait:hover,
.marine-channel:hover,
.marine-sound:hover {
  fill: rgba(74, 144, 226, 0.15);
  stroke: #FFD700;
  stroke-width: 2px;
  opacity: 1;
}