:root {
  --bg-color: #0a0e27;
  --font-color: #E0CDB2;
  --accent-color: #4a9eff;
  --button-bg: #1e2749;
  --button-hover: #2d3a5f;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: var(--bg-color);
  color: var(--font-color);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

/*
 * CSS Grid Layout Structure:
 * Row 1: Title (auto - takes what it needs)
 * Row 2: Disclaimer (auto)
 * Row 3: Language selector (auto - positioned absolute, doesn't take grid space)
 * Row 4: Controls (auto)
 * Row 5: Scale bar (auto)
 * Row 6: Canvas (1fr - fills remaining space)
 * Row 7: Orbital info bar (auto)
 *
 * Benefits:
 * - Canvas automatically calculates remaining space
 * - No more manual padding calculations
 * - Orbital bar is part of normal flow (not fixed)
 * - Canvas stops exactly at orbital bar border
 * - Adding new elements doesn't break layout
 */
#app {
  width: 100%;
  height: 100vh;
  display: grid;
  grid-template-rows: auto auto auto auto 1fr auto;
  position: relative;
}

/* Title */
.app-title {
  font-family: sans-serif;
  text-align: center;
  color: #E0CDB2;
  font-size: 1.8em;
  font-weight: bold;
  margin: 20px 0 12.6px 0;
  z-index: 100;
}

.app-title a {
  margin-left: 0.5rem;
  font-family: sans-serif;
  font-size: 0.5em;
  font-style: italic;
  text-decoration: underline;
  color: #E0CDB2;
  transition: color 0.3s ease;
}

.app-title a:hover {
  color: rgb(0, 51, 255);
}

/* Language Selector */
.language-selector {
  position: absolute;
  top: 15px;
  right: 20px;
  display: flex;
  gap: 8px;
  z-index: 100;
}

.lang-btn {
  padding: 6px 12px;
  background: var(--button-bg);
  color: var(--font-color);
  border: 2px solid transparent;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.3s;
}

.lang-btn:hover {
  background: var(--button-hover);
}

.lang-btn.active {
  border-color: var(--accent-color);
  background: var(--accent-color);
}

/* Controls */
.controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 30px;
  padding: 5px;
  z-index: 100;
  flex-wrap: wrap;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.control-btn {
  padding: 10px 20px;
  background: #3e55a8;
  color: var(--font-color);
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: bold;
  transition: background 0.3s;
  min-width: 100px;
}

.control-btn:hover {
  background: #2d3a5f;
}

.control-btn.paused {
  background: #ff6b6b;
}

.control-btn.paused:hover {
  background: #ff8787;
}

label {
  font-size: 1rem;
  font-weight: bold;
}

#speed-slider {
  width: 150px;
  height: 6px;
  border-radius: 5px;
  outline: none;
  -webkit-appearance: none;
  background: var(--button-bg);
}

#speed-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-color);
  cursor: pointer;
}

#speed-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-color);
  cursor: pointer;
  border: none;
}

#speed-value {
  font-size: 1rem;
  font-weight: bold;
  color: var(--accent-color);
  min-width: 45px;
}

/* Real Scale Bar */
.scale-bar-wrapper {
  width: 100%;
  padding: 10px 20px;
  background: var(--bg-color);
  z-index: 100;
}

.scale-bar-title {
  font-size: 1rem;
  font-weight: bold;
  text-align: center;
  margin-bottom: 8px;
  color: var(--accent-color);
}

.scale-bar {
  position: relative;
  height: 55px;
  width: 52%;
  margin: 0 auto;
  background: rgba(30, 39, 73, 0.5);
  border-radius: 8px;
  border: 1px solid rgba(74, 158, 255, 0.3);
  overflow: visible;
  padding: 0 20px 20px 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* Hide scrollbar but keep functionality */
.scale-bar::-webkit-scrollbar {
  display: none;
}

.scale-bar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.scale-bar-inner-label {
  position: absolute;
  top: 32px;
  left: 4px;
  font-size: 0.5rem;
  color: #E0CDB2;
  white-space: nowrap;
}

/* Three-layer structure for scale bar */
.scale-bar-planet {
  position: absolute;
  transform: translateX(-50%);
}

.scale-bar-planet-no-label {
  /* No additional positioning needed */
}

/* Layer 1: Distance markers at top */
.scale-bar-distance-marker {
  position: absolute;
  top: 2px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
}

/* Special positioning for Pluto's marker to prevent overflow */
.scale-bar-distance-marker-pluto {
  left: auto;
  right: 0;
  transform: translateX(0);
  text-align: right;
}

.scale-bar-marker-line {
  display: none;
}

.scale-bar-marker-label {
  font-size: 0.6rem;
  color: var(--accent-color);
  white-space: nowrap;
  font-weight: bold;
}

/* Layer 2: Planet icons in middle */
.scale-bar-planet-icon {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  border-radius: 50%;
  box-shadow: 0 0 5px rgba(255, 255, 255, 0.3);
}

/* Layer 3: Planet names at bottom */
.scale-bar-planet-name {
  position: absolute;
  top: 32px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.7rem;
  color: #E0CDB2;
  white-space: nowrap;
  text-align: center;
}

/* Adjust Pluto's name slightly to the left */
.scale-bar-planet-name-pluto {
  transform: translateX(-60%);
}

/* Orbital Period Information Bar */
.orbital-info-bar {
  background: rgba(30, 39, 73, 0.95);
  padding: 15px 20px;
  border-top: 2px solid var(--accent-color);
  z-index: 100;
}

.orbital-info-title {
  font-size: 0.9rem;
  font-weight: bold;
  color: var(--accent-color);
  text-align: center;
  margin: 0 0 10px 0;
}

.orbital-info-content {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 15px;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.9);
}

.planet-period {
  display: flex;
  align-items: center;
  gap: 5px;
}

.planet-period-name {
  font-weight: bold;
  color: var(--accent-color);
}

.planet-period-value {
  color: #E0CDB2;
}

/* Info Panel */
.info-panel {
  position: absolute;
  top: 120px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(30, 39, 73, 0.95);
  padding: 15px 25px;
  border-radius: 8px;
  border: 2px solid var(--accent-color);
  z-index: 100;
  font-size: 1.1rem;
  font-weight: bold;
  color: var(--accent-color);
  text-align: center;
}

/* Canvas */
#solar-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  min-height: 300px;
}

/* Disclaimer */
.disclaimer {
  font-size: 0.75rem;
  color: #E0CDB2;
  text-align: center;
  font-style: italic;
  padding: 0 15px 5px 15px;
  margin: 0 auto;
  max-width: 600px;
  z-index: 100;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .app-title {
    font-size: 1.3rem;
    margin: 10px 0 5px 0;
  }

  .app-title a {
    font-size: 0.35em;
    display: block;
    margin: 2px 0 0 0;
  }

  .language-selector {
    top: 10px;
    right: 10px;
  }

  .controls {
    gap: 15px;
    padding: 5px;
  }

  .control-btn {
    padding: 8px 15px;
    font-size: 0.85rem;
    min-width: 80px;
  }

  label {
    font-size: 0.85rem;
  }

  #speed-slider {
    width: 100px;
  }

  #speed-value {
    font-size: 0.85rem;
  }

  .info-panel {
    top: 100px;
    font-size: 0.9rem;
    padding: 10px 15px;
  }

  .disclaimer {
    font-size: 0.65rem;
    padding: 0 10px 3px 10px;
  }

  #solar-canvas {
    height: 600px;
    min-height: 500px;
  }

  /* Switch to scrollable layout on mobile */
  body {
    overflow-y: auto;
    height: auto;
  }

  #app {
    height: auto;
    min-height: 100vh;
  }

  .scale-bar-wrapper {
    padding: 8px 10px;
  }

  .scale-bar-title {
    font-size: 0.85rem;
    margin-bottom: 5px;
  }

  .scale-bar {
    height: 50px;
    width: 90%;
  }

  .scale-bar-planet-name {
    font-size: 0.55rem;
  }

  .scale-bar-marker-label {
    font-size: 0.5rem;
  }

  .scale-bar-planet-icon {
    top: 15px;
  }

  .scale-bar-planet-name {
    top: 28px;
  }

  .scale-bar-inner-label {
    top: 28px;
    font-size: 0.45rem;
  }

  .orbital-info-bar {
    padding: 10px 15px;
  }

  .orbital-info-title {
    font-size: 0.8rem;
    margin-bottom: 8px;
  }

  .orbital-info-content {
    font-size: 0.65rem;
    gap: 10px;
  }
}

@media (max-width: 480px) {
  .app-title {
    font-size: 1rem;
  }

  .controls {
    flex-direction: column;
    gap: 8px;
  }

  .control-group {
    width: 100%;
    justify-content: center;
  }

  #speed-slider {
    width: 120px;
  }

  .scale-bar {
    width: 95%;
    height: 45px;
  }

  .scale-bar-marker-label {
    font-size: 0.45rem;
  }

  .scale-bar-planet-icon {
    top: 13px;
  }

  .scale-bar-planet-name {
    top: 25px;
    font-size: 0.5rem;
  }

  .scale-bar-inner-label {
    top: 25px;
    font-size: 0.4rem;
  }

  .orbital-info-content {
    font-size: 0.6rem;
    gap: 8px;
  }

  .info-panel {
    font-size: 0.8rem;
    padding: 8px 12px;
  }
}