:root {
  /* Fixed Space Theme Colors (Sky remains black) */
  --sky-bg: #0b0e14;
  --sky-text: #e0e0e0;
  --sky-text-dim: #888;
  --sky-accent: #4a90e2;

  /* Theme-Aware Warp Ring Colors (Defaults to Dark) */
  --warp-bg: linear-gradient(
    180deg,
    rgba(20, 25, 35, 0.8) 0%,
    rgba(10, 15, 25, 0.9) 100%
  );
  --warp-text: #e0e0e0;
  --warp-text-dim: #888;
  --warp-border: #444;
  --warp-accent: #4a90e2;
  --map-bg: #0b0e14;
  --map-grid: rgba(255, 255, 255, 0.05);
  --coord-bg: rgba(255, 255, 255, 0.05);
}

@media (prefers-color-scheme: light) {
  :root {
    /* Only Warp Ring section changes in light theme */
    --warp-bg: linear-gradient(
      180deg,
      rgba(230, 235, 245, 0.8) 0%,
      rgba(220, 225, 235, 0.9) 100%
    );
    --warp-text: #1a1a1a;
    --warp-text-dim: #666;
    --warp-border: #ccc;
    --warp-accent: #2a6dbd;
    --map-bg: #ffffff;
    --map-grid: rgba(0, 0, 0, 0.05);
    --coord-bg: rgba(0, 0, 0, 0.05);
  }
}

body {
  background: var(--sky-bg);
  color: var(--sky-text);
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: 100vh;
  margin: 0;
  padding: 4rem 0;
  box-sizing: border-box;
  position: relative;
  transition:
    background 0.3s,
    color 0.3s;
}

h1,
p {
  padding-left: 2rem;
  padding-right: 2rem;
  max-width: 800px;
  text-align: center;
}

/* Starfield effect - always visible */
body::before,
body::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  background: transparent;
  z-index: -1;
  opacity: 1; /* Always 100% opacity for stars */
}

body::before {
  box-shadow:
    10vw 20vh #fff,
    35vw 45vh #fff,
    80vw 10vh #fff,
    15vw 85vh #fff,
    55vw 15vh #fff,
    90vw 60vh #fff,
    25vw 30vh #fff,
    70vw 75vh #fff,
    45vw 90vh #fff,
    5vw 50vh #fff,
    65vw 5vh #fff,
    85vw 25vh #fff,
    12vw 12vh rgba(255, 255, 255, 0.5),
    42vw 82vh rgba(255, 255, 255, 0.5),
    72vw 32vh rgba(255, 255, 255, 0.5),
    92vw 92vh rgba(255, 255, 255, 0.5);
}

body::after {
  width: 2px;
  height: 2px;
  box-shadow:
    20vw 10vh #fff,
    40vw 60vh #fff,
    60vw 20vh #fff,
    80vw 80vh #fff,
    10vw 90vh #fff,
    30vw 40vh #fff,
    50vw 70vh #fff,
    70vw 10vh #fff,
    95vw 45vh #fff;
  opacity: 0.5;
}

.planet-container {
  position: relative;
  margin-bottom: 3rem;
  display: flex;
  justify-content: center;
  align-items: center;
}

.planet {
  width: 200px;
  height: 200px;
  background: radial-gradient(circle at 30% 30%, var(--sky-accent), #1b2735);
  border-radius: 50%;
  box-shadow:
    inset -20px -20px 50px rgba(0, 0, 0, 0.5),
    inset 10px 10px 20px rgba(255, 255, 255, 0.1),
    0 0 60px var(--sky-accent);
  position: relative;
  overflow: hidden;
  z-index: 2;
}

/* Surface craters/texture */
.planet::before {
  content: "";
  position: absolute;
  width: 100%;
  height: 100%;
  background-image:
    radial-gradient(circle at 70% 20%, rgba(0, 0, 0, 0.15) 5%, transparent 6%),
    radial-gradient(circle at 40% 60%, rgba(0, 0, 0, 0.15) 8%, transparent 9%),
    radial-gradient(circle at 80% 70%, rgba(0, 0, 0, 0.1) 3%, transparent 4%),
    radial-gradient(
      circle at 20% 40%,
      rgba(255, 255, 255, 0.05) 10%,
      transparent 11%
    );
}

.ring {
  position: absolute;
  width: 340px;
  height: 80px;
  border: 12px solid rgba(255, 255, 255, 0.08);
  border-top-color: transparent;
  border-bottom-color: rgba(255, 255, 255, 0.12);
  border-radius: 50%;
  transform: rotate(-20deg);
  z-index: 3;
  pointer-events: none;
}

/* Back half of the ring */
.ring-back {
  position: absolute;
  width: 340px;
  height: 80px;
  border: 12px solid rgba(255, 255, 255, 0.08);
  border-bottom-color: transparent;
  border-top-color: rgba(255, 255, 255, 0.04);
  border-radius: 50%;
  transform: rotate(-20deg);
  z-index: 1;
  pointer-events: none;
}

.atmosphere {
  position: absolute;
  width: 230px;
  height: 230px;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(74, 144, 226, 0.1) 0%,
    transparent 70%
  );
  box-shadow: 0 0 40px rgba(74, 144, 226, 0.1);
  z-index: 0;
}

h1 {
  font-size: 2.5rem;
  margin: 0.5rem 0;
  text-transform: uppercase;
  letter-spacing: 4px;
  color: var(--sky-text);
}

p {
  color: var(--sky-text-dim);
  font-style: italic;
}

.warp-ring {
  margin-top: 3rem;
  padding: 4rem 2rem;
  background: var(--warp-bg);
  border-top: 1px dashed var(--warp-border);
  border-bottom: 1px dashed var(--warp-border);
  color: var(--warp-text);
  text-align: center;
  width: 100%;
  box-sizing: border-box;
  transition:
    background 0.3s,
    border 0.3s,
    color 0.3s;
}

.warp-ring-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3rem;
  margin-top: 3rem;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
}

@media (min-width: 800px) {
  .warp-ring-content {
    flex-direction: row-reverse;
    justify-content: space-between;
    align-items: flex-start;
    text-align: left;
  }

  .star-map-wrapper {
    flex: 0 0 auto;
    width: 60%;
  }

  .warp-links {
    flex: 1;
    margin-top: 0;
    padding-top: 1rem;
  }
}

.star-map-container {
  margin: 0 auto 2rem;
  position: relative;
  width: 60vw;
  height: 60vw;
  min-width: 20em;
  min-height: 20em;
  max-width: 600px;
  max-height: 600px;
  background: var(--map-bg);
  border: 1px solid var(--warp-border);
  border-radius: 4px;
  overflow: hidden;
  transition:
    background 0.3s,
    border 0.3s;
  display: flex;
  justify-content: center;
  align-items: center;
}

#three-container canvas {
  width: 100% !important;
  height: 100% !important;
}

@media (min-width: 800px) {
  .star-map-container {
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
  }
}

.warp-ring h2 {
  font-size: 0.9rem;
  color: var(--warp-text-dim);
  margin-bottom: 1rem;
  text-transform: uppercase;
}

.warp-ring a {
  color: var(--warp-accent);
  text-decoration: none;
  font-weight: bold;
  transition:
    color 0.3s,
    text-shadow 0.3s,
    transform 0.3s;
}

.warp-links {
  list-style: none;
  padding: 0;
}

.warp-links li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.5rem;
  width: 100%;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.2s ease;
  list-style: none;
}

.warp-links li:hover,
.warp-links li.active {
  background: rgba(255, 255, 255, 0.05);
}

.warp-links li a {
  color: var(--warp-accent);
  text-decoration: none;
  font-weight: bold;
  transition:
    color 0.3s,
    text-shadow 0.3s,
    transform 0.3s;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  text-align: left;
}

.warp-links li a:hover,
.warp-links li a.active {
  color: #fff;
  text-shadow: 0 0 10px var(--warp-accent);
}

@media (prefers-color-scheme: light) {
  .warp-links li a:hover,
  .warp-links li a.active {
    color: var(--warp-accent);
    text-shadow: none;
    text-decoration: underline;
  }
}

.coord {
  font-family: "Courier New", Courier, monospace;
  background: var(--coord-bg);
  color: var(--warp-text);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85em;
  flex: 0 0 auto;
  white-space: nowrap;
  cursor: default;
}

/* Coordinate Display Class */
.coord-display {
  font-family: "Courier New", Courier, monospace;
  background: var(--coord-bg);
  padding: 2px 6px;
  border-radius: 4px;
}

/* Map Labels */
.map-label {
  position: absolute;
  bottom: 5px;
  right: 8px;
  font-size: 0.6rem;
  color: #444;
  pointer-events: none;
  z-index: 10;
}

/* Map Legend styles */
.map-legend {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  margin-bottom: 2rem;
  font-size: 0.75rem;
  color: #888;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.legend-marker {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.legend-marker.station {
  border: 1px solid #2ecc71;
  position: relative;
}

.legend-marker.station::before,
.legend-marker.station::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  background: #2ecc71;
  transform: translate(-50%, -50%);
}

.legend-marker.station::before {
  width: 14px;
  height: 1px;
}

.legend-marker.station::after {
  width: 1px;
  height: 14px;
}

.legend-marker.neighbor {
  background: #4a90e2;
  opacity: 0.6;
}

/* Space Port Status Badge */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(46, 204, 113, 0.1);
  border: 1px solid rgba(46, 204, 113, 0.3);
  color: #2ecc71;
  padding: 0.4rem 1rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 1.5rem 0;
}

.status-badge::before {
  content: "";
  width: 8px;
  height: 8px;
  background: #2ecc71;
  border-radius: 50%;
  box-shadow: 0 0 10px #2ecc71;
}

.space-port {
  width: 100%;
  max-width: 800px;
  background: var(--warp-bg);
  border-top: 1px dashed var(--warp-border);
  border-bottom: 1px dashed var(--warp-border);
  border-left: 1px solid var(--warp-border);
  border-right: 1px solid var(--warp-border);
  border-radius: 8px;
  padding: 1.5rem;
  margin: 1rem 0 4rem 0;
  text-align: left;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.traffic-log,
.mission-archive {
  width: 100%;
  overflow-x: auto;
}

.traffic-log h3,
.mission-archive h3 {
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--warp-text-dim);
  margin-top: 0;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--warp-border);
  padding-bottom: 0.5rem;
}

.traffic-table,
.archive-table {
  width: 100%;
  border-collapse: collapse;
  font-family: "Courier New", Courier, monospace;
  font-size: 0.85rem;
}

.traffic-table th,
.archive-table th {
  text-align: left;
  color: var(--warp-text-dim);
  font-size: 0.7rem;
  text-transform: uppercase;
  padding: 0.5rem;
  border-bottom: 1px solid var(--map-grid);
}

.traffic-table td,
.archive-table td {
  padding: 0.6rem 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.ship-id {
  font-weight: bold;
  color: var(--warp-accent);
  white-space: nowrap;
}

.status-label,
.event-label {
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: bold;
  display: inline-block;
  min-width: 80px;
  text-align: center;
}

/* Preparation Label */
.preparation .status-label {
  background: rgba(241, 196, 15, 0.15);
  color: #f1c40f;
  border: 1px solid rgba(241, 196, 15, 0.3);
}

/* Outgoing / Departed Label */
.outgoing .status-label,
.departed .event-label {
  background: rgba(230, 126, 34, 0.15);
  color: #e67e22;
  border: 1px solid rgba(230, 126, 34, 0.3);
}

/* Incoming / Arrived Label */
.incoming .status-label,
.arrived .event-label {
  background: rgba(52, 152, 219, 0.15);
  color: #3498db;
  border: 1px solid rgba(52, 152, 219, 0.3);
}

.location,
.eta,
.timestamp {
  color: var(--warp-text-dim);
}

.coord-sm {
  font-size: 0.7rem;
  opacity: 0.8;
  font-family: "Courier New", Courier, monospace;
}

.archive-table td {
  font-size: 0.8rem;
}

@media (max-width: 600px) {
  .traffic-table th:nth-child(3),
  .traffic-table td:nth-child(3),
  .traffic-table th:nth-child(4),
  .traffic-table td:nth-child(4),
  .archive-table th:nth-child(3),
  .archive-table td:nth-child(3),
  .archive-table th:nth-child(4),
  .archive-table td:nth-child(4) {
    display: none;
  }
}

/* Footer styles */
footer {
  margin-top: 4rem;
  padding: 2rem;
  font-size: 0.9rem;
  color: #555;
  text-align: center;
}

footer a {
  color: #4a90e2;
  text-decoration: none;
}
