:root {
  --bg-1: #040611;
  --bg-2: #0e1635;
  --text: #f3f7ff;
  --muted: #c4d3ff;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Segoe UI", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  background:
    radial-gradient(circle at 12% 10%, #263d87 0%, transparent 28%),
    radial-gradient(circle at 84% 18%, #4e1e70 0%, transparent 24%),
    linear-gradient(160deg, var(--bg-1), var(--bg-2));
}

body {
  position: relative;
  overflow: hidden;
  padding: 0;
}

#starfield {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.hud,
.space-viewport,
.help-chip,
.game-float-chip {
  position: relative;
  z-index: 1;
}

.hud {
  position: fixed;
  top: 14px;
  left: 14px;
  right: 14px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid rgba(180, 205, 255, 0.25);
  background: rgba(10, 18, 40, 0.56);
  backdrop-filter: blur(6px);
  pointer-events: none;
}

.hud h1 {
  margin: 0;
  font-size: clamp(1.05rem, 3.3vw, 1.55rem);
}

.hud p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: clamp(0.78rem, 2.2vw, 0.95rem);
}

.space-viewport {
  position: fixed;
  inset: 0;
  touch-action: none;
  cursor: grab;
}

.space-viewport.dragging {
  cursor: grabbing;
}

.space-scene {
  position: absolute;
  width: 2600px;
  height: 1800px;
  transform: translate3d(0, 0, 0);
  will-change: transform;
}

.links-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  z-index: 1;
}

.links-layer line {
  stroke: rgba(120, 210, 255, 0.65);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 0 6px rgba(120, 210, 255, 0.35));
}

.planet {
  position: absolute;
  color: var(--text);
  text-decoration: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  user-select: none;
  transform: translate3d(0, 0, 0);
  transition: filter 200ms ease;
  z-index: 2;
}

.planet:hover {
  filter: brightness(1.12);
}

.planet-image {
  width: var(--size, 118px);
  height: var(--size, 118px);
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(236, 243, 255, 0.44);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.2) inset,
    0 0 26px rgba(130, 165, 255, 0.42),
    0 14px 26px rgba(3, 7, 19, 0.5);
}

.planet-label {
  font-weight: 700;
  text-align: center;
  line-height: 1.3;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.65);
  padding: 0 8px;
  max-width: 170px;
  word-break: break-word;
}

.planet-server {
  font-size: 0.78rem;
  color: var(--muted);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.65);
}

.help-chip {
  position: fixed;
  left: 12px;
  bottom: 12px;
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--muted);
  border: 1px solid rgba(180, 205, 255, 0.2);
  background: rgba(10, 18, 40, 0.52);
  font-size: 0.78rem;
}

/* 右下：ミニゲーム導線（help-chip と同系の浮きチップ） */
.game-float-chip {
  position: fixed;
  right: 12px;
  bottom: 12px;
  left: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border-radius: 999px;
  border: 1px solid rgba(180, 205, 255, 0.2);
  background: rgba(10, 18, 40, 0.52);
  backdrop-filter: blur(6px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.28);
  line-height: 0;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: filter 160ms ease, transform 160ms ease;
}

.game-float-chip:hover {
  filter: brightness(1.08);
}

.game-float-chip:active {
  transform: scale(0.96);
}

.game-float-chip img {
  display: block;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: contain;
  vertical-align: top;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 3;
  background: rgba(0, 0, 0, 0.28);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.overlay.open {
  opacity: 1;
  pointer-events: none;
}

.info-panel {
  position: fixed;
  z-index: 4;
  border: 1px solid rgba(180, 205, 255, 0.28);
  border-radius: 16px;
  background: rgba(10, 18, 40, 0.78);
  backdrop-filter: blur(10px);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
  color: var(--text);
  opacity: 0;
  transform: translate3d(0, 8px, 0);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.info-panel.open {
  opacity: 1;
  transform: translate3d(0, 0, 0);
  pointer-events: auto;
}

.panel-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 10;
  /* タッチしやすい最小サイズ（.panel-body より手前に重ねる） */
  min-width: 44px;
  min-height: 44px;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 12px;
  border: 1px solid rgba(180, 205, 255, 0.28);
  background: rgba(5, 10, 24, 0.5);
  color: var(--text);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(255, 255, 255, 0.12);
}

.panel-body {
  padding: 18px 16px 16px;
}

.panel-title {
  margin: 0 38px 6px 0;
  font-size: 1.15rem;
}

.panel-meta {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.panel-desc {
  margin: 0 0 14px;
  color: var(--text);
  line-height: 1.7;
}

.panel-actions {
  display: flex;
  gap: 10px;
}

.panel-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(120, 210, 255, 0.6);
  background: linear-gradient(180deg, #2a4fc0, #223688);
  color: #eef7ff;
  text-decoration: none;
  font-weight: 700;
}

@media (min-width: 761px) {
  /* 右端ではなく「中央より右」にボックス（惑星は左寄せカメラとセット） */
  .info-panel {
    top: 50%;
    left: clamp(48%, calc(50% + 24px), 58%);
    right: auto;
    width: min(400px, 40vw);
    transform: translate3d(0, calc(-50% + 8px), 0);
  }

  .info-panel.open {
    transform: translate3d(0, -50%, 0);
  }
}

@media (max-width: 760px) {
  .hud {
    top: 10px;
    left: 10px;
    right: 10px;
    padding: 8px 10px;
  }

  .help-chip {
    left: 10px;
    bottom: 10px;
    font-size: 0.72rem;
    padding: 7px 10px;
  }

  .game-float-chip {
    right: 10px;
    bottom: 10px;
    padding: 2px;
  }

  .game-float-chip img {
    width: 24px;
    height: 24px;
  }

  .info-panel {
    top: auto;
    left: 10px;
    right: 10px;
    bottom: 10px;
    width: auto;
    max-height: 56vh;
    overflow: auto;
    transform: translate3d(0, 8px, 0);
  }

  .info-panel.open {
    transform: translate3d(0, 0, 0);
  }
}
