* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #02040a;
  color: #e2e8f0;
  font-family: 'Segoe UI', 'Hiragino Kaku Gothic ProN', 'Meiryo', sans-serif;
}

#canvas-container {
  position: fixed;
  inset: 0;
  z-index: 1;
  cursor: grab;
}

#canvas-container:active {
  cursor: grabbing;
}

/* ローディング画面 */
#loading-screen {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: radial-gradient(circle at center, #0f172a 0%, #020617 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  transition: opacity 0.55s ease;
}

#loading-screen.fade-out {
  opacity: 0;
  pointer-events: none;
}

.loader-ring {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: 3px solid rgba(56, 189, 248, 0.2);
  border-top-color: #38bdf8;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loader-title {
  font-size: 1.35rem;
  letter-spacing: 0.14em;
  color: #38bdf8;
  font-weight: 700;
}

.loader-sub {
  font-size: 0.88rem;
  color: #94a3b8;
}

/* 3D空間上の天体ターゲットマーカー */
#hud-markers {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.hud-marker {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  pointer-events: auto;
  cursor: pointer;
  margin-left: -9px;
  margin-top: -9px;
  transition: filter 0.15s ease;
}

.hud-marker:hover {
  filter: brightness(1.35);
  z-index: 15;
}

.marker-diamond {
  width: 14px;
  height: 14px;
  border: 2px solid #38bdf8;
  transform: rotate(45deg);
  background: rgba(15, 23, 42, 0.55);
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.45);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.hud-marker.locked .marker-diamond {
  width: 18px;
  height: 18px;
  transform: rotate(45deg) scale(1.18);
  box-shadow: 0 0 14px #38bdf8, inset 0 0 6px #ffffff;
}

.marker-label {
  display: flex;
  flex-direction: column;
  background: rgba(2, 6, 23, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 4px;
  padding: 2px 7px;
  backdrop-filter: blur(4px);
}

.hud-marker.locked .marker-label {
  border-color: #38bdf8;
  background: rgba(14, 116, 144, 0.35);
}

.marker-name {
  font-size: 0.75rem;
  font-weight: 700;
  color: #f8fafc;
  white-space: nowrap;
}

.marker-dist {
  font-size: 0.65rem;
  color: #94a3b8;
  white-space: nowrap;
}

/* 1人称コックピット視点フレーム */
#cockpit-frame {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  border: 18px solid rgba(15, 23, 42, 0.72);
  box-shadow: inset 0 0 90px rgba(2, 132, 199, 0.28);
}

#cockpit-frame::before,
#cockpit-frame::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(to bottom, rgba(56,189,248,0.45), transparent 30%, transparent 70%, rgba(56,189,248,0.45));
}
#cockpit-frame::before { left: 24%; transform: skewX(-16deg); }
#cockpit-frame::after { right: 24%; transform: skewX(16deg); }

.cockpit-crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 44px;
  height: 44px;
  transform: translate(-50%, -50%);
  border: 1.5px dashed rgba(56, 189, 248, 0.55);
  border-radius: 50%;
}

/* トップヘッダーHUD */
#top-hud {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
  background: rgba(15, 23, 42, 0.78);
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 999px;
  padding: 6px 16px 6px 10px;
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
}

.hud-brand {
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #38bdf8;
}

.status-badge {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 3px 11px;
  border-radius: 999px;
  letter-spacing: 0.04em;
}

.status-normal {
  background: rgba(14, 165, 233, 0.18);
  color: #7dd3fc;
  border: 1px solid rgba(56, 189, 248, 0.4);
}

.status-auto {
  background: rgba(16, 185, 129, 0.22);
  color: #6ee7b7;
  border: 1px solid #10b981;
}

.status-warp {
  background: rgba(168, 85, 247, 0.28);
  color: #e9d5ff;
  border: 1px solid #c084fc;
}

.icon-btn {
  background: rgba(30, 41, 59, 0.8);
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 0.76rem;
  cursor: pointer;
  transition: all 0.15s;
}

.icon-btn:hover {
  border-color: #38bdf8;
  color: #ffffff;
}

/* 左サイドパネル：天体ナビゲーション */
#left-panel {
  position: fixed;
  top: 68px;
  left: 16px;
  bottom: 92px;
  width: 280px;
  z-index: 10;
  background: rgba(15, 23, 42, 0.76);
  border: 1px solid rgba(56, 189, 248, 0.28);
  border-radius: 12px;
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.55);
}

.panel-header {
  padding: 12px 14px 8px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}

.panel-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: #38bdf8;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

.filter-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}

.tab-btn {
  background: rgba(30, 41, 59, 0.7);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 6px;
  padding: 5px 2px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.tab-btn.active,
.tab-btn:hover {
  background: rgba(14, 165, 233, 0.25);
  color: #f8fafc;
  border-color: #38bdf8;
}

#celestial-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

#celestial-list::-webkit-scrollbar {
  width: 5px;
}
#celestial-list::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.3);
  border-radius: 4px;
}

.celestial-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  border-radius: 8px;
  background: rgba(30, 41, 59, 0.48);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
}

.celestial-item:hover {
  background: rgba(30, 41, 59, 0.85);
  border-color: rgba(56, 189, 248, 0.35);
}

.celestial-item.active {
  background: rgba(14, 116, 144, 0.36);
  border-color: #38bdf8;
}

.item-left {
  display: flex;
  align-items: center;
  gap: 9px;
}

.planet-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  flex-shrink: 0;
}

.item-title {
  font-size: 0.84rem;
  font-weight: 700;
  color: #f1f5f9;
}

.item-title small {
  font-size: 0.7rem;
  color: #94a3b8;
  font-weight: 400;
  margin-left: 3px;
}

.item-sub {
  font-size: 0.68rem;
  color: #94a3b8;
}

.warp-quick-btn {
  background: rgba(14, 165, 233, 0.18);
  color: #7dd3fc;
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.warp-quick-btn:hover {
  background: #0284c7;
  color: #ffffff;
}

/* 右サイドパネル：レーダーミニマップ ＆ 天体詳細データカード */
#right-panel {
  position: fixed;
  top: 68px;
  right: 16px;
  bottom: 92px;
  width: 320px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.glass-card {
  pointer-events: auto;
  background: rgba(15, 23, 42, 0.78);
  border: 1px solid rgba(56, 189, 248, 0.28);
  border-radius: 12px;
  padding: 12px 14px;
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.55);
}

.radar-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

#radar-canvas {
  background: radial-gradient(circle, rgba(14, 116, 144, 0.22) 0%, rgba(2, 6, 23, 0.85) 100%);
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 50%;
  flex-shrink: 0;
}

.radar-legend {
  font-size: 0.72rem;
  color: #94a3b8;
  line-height: 1.5;
}

.radar-legend strong {
  color: #38bdf8;
  display: block;
  margin-bottom: 3px;
  font-size: 0.78rem;
}

.info-card {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.category-badge {
  display: inline-block;
  align-self: flex-start;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid #38bdf8;
  color: #38bdf8;
}

.target-titles {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

#info-name {
  font-size: 1.45rem;
  font-weight: 800;
  color: #f8fafc;
}

#info-en {
  font-size: 0.9rem;
  color: #94a3b8;
}

.action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.primary-action-btn,
.secondary-action-btn {
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s;
}

.primary-action-btn {
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: #ffffff;
  border: 1px solid #38bdf8;
}

.primary-action-btn:hover {
  filter: brightness(1.15);
}

.primary-action-btn.autopilot-engaged {
  background: linear-gradient(135deg, #059669, #10b981);
  border-color: #6ee7b7;
}

.secondary-action-btn {
  background: rgba(30, 41, 59, 0.85);
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.35);
}

.secondary-action-btn.active,
.secondary-action-btn:hover {
  background: rgba(14, 165, 233, 0.25);
  color: #ffffff;
  border-color: #38bdf8;
}

.spec-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 5px;
  background: rgba(2, 6, 23, 0.55);
  padding: 9px 11px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.16);
}

.spec-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.74rem;
  border-bottom: 1px dashed rgba(148, 163, 184, 0.12);
  padding-bottom: 3px;
}

.spec-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.spec-label {
  color: #94a3b8;
}

.spec-val {
  color: #f1f5f9;
  font-weight: 600;
  text-align: right;
}

.spec-highlight {
  color: #38bdf8;
}

#info-desc {
  font-size: 0.78rem;
  line-height: 1.62;
  color: #cbd5e1;
  background: rgba(30, 41, 59, 0.38);
  padding: 9px 11px;
  border-radius: 8px;
}

/* 下部フライトコンソールHUD */
#bottom-hud {
  position: fixed;
  bottom: 14px;
  left: 16px;
  right: 16px;
  height: 66px;
  z-index: 10;
  background: rgba(15, 23, 42, 0.82);
  border: 1px solid rgba(56, 189, 248, 0.32);
  border-radius: 12px;
  backdrop-filter: blur(12px);
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
}

.hud-section {
  display: flex;
  align-items: center;
  gap: 10px;
}

.speed-box {
  min-width: 195px;
}

.speed-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.74rem;
  margin-bottom: 4px;
}

.speed-label {
  color: #94a3b8;
  font-weight: 600;
}

#hud-speed-val {
  color: #38bdf8;
  font-weight: 800;
  font-family: Consolas, monospace;
}

.speed-bar-bg {
  width: 100%;
  height: 7px;
  background: rgba(2, 6, 23, 0.8);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

#hud-speed-bar {
  height: 100%;
  width: 5%;
  background: linear-gradient(90deg, #0ea5e9, #a855f7);
  transition: width 0.08s ease;
}

.hud-btn {
  background: rgba(30, 41, 59, 0.8);
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 8px;
  padding: 7px 11px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.hud-btn:hover {
  border-color: #38bdf8;
  color: #ffffff;
}

.hud-btn.active {
  background: rgba(14, 165, 233, 0.25);
  color: #7dd3fc;
  border-color: #38bdf8;
}

#btn-warp-toggle.active {
  background: rgba(168, 85, 247, 0.32);
  color: #f3e8ff;
  border-color: #c084fc;
  box-shadow: 0 0 14px rgba(168, 85, 247, 0.45);
}

.time-control {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.75rem;
  color: #cbd5e1;
  background: rgba(2, 6, 23, 0.45);
  padding: 6px 11px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.2);
}

#time-speed-slider {
  width: 85px;
  accent-color: #38bdf8;
  cursor: pointer;
}

#time-speed-val {
  min-width: 36px;
  color: #38bdf8;
  font-weight: 700;
}

/* 操作ヘルプモーダル */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(2, 6, 23, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.hidden {
  display: none !important;
}

.modal-box {
  width: 540px;
  max-width: 92vw;
  background: #0f172a;
  border: 1px solid #38bdf8;
  border-radius: 14px;
  padding: 22px 26px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.75);
}

.modal-box h2 {
  color: #38bdf8;
  font-size: 1.15rem;
  margin-bottom: 14px;
}

.key-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}

.key-item {
  background: rgba(30, 41, 59, 0.65);
  padding: 8px 11px;
  border-radius: 8px;
  font-size: 0.78rem;
}

.key-item kbd {
  display: inline-block;
  background: #1e293b;
  border: 1px solid #475569;
  border-radius: 4px;
  padding: 2px 6px;
  color: #38bdf8;
  font-weight: 700;
  margin-right: 5px;
}

/* 全UI非表示モード＆解説パネルのみ非表示モード */
.highlight-hide-btn {
  background: rgba(14, 165, 233, 0.22);
  border-color: #38bdf8;
  color: #e0f2fe;
  font-weight: 700;
}

#btn-restore-ui {
  position: fixed;
  top: 14px;
  right: 16px;
  z-index: 50;
  background: rgba(15, 23, 42, 0.75);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.45);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  opacity: 0.28;
  transition: opacity 0.2s ease, transform 0.2s ease;
  backdrop-filter: blur(6px);
}

#btn-restore-ui:hover {
  opacity: 1.0;
  transform: scale(1.04);
}

#top-hud,
#left-panel,
#right-panel,
#bottom-hud,
#hud-markers {
  transition: opacity 0.28s ease, transform 0.28s ease;
}

body.panels-hidden #left-panel {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-310px);
}

body.panels-hidden #right-panel {
  opacity: 0;
  pointer-events: none;
  transform: translateX(350px);
}

body.ui-hidden #top-hud,
body.ui-hidden #left-panel,
body.ui-hidden #right-panel,
body.ui-hidden #bottom-hud,
body.ui-hidden #hud-markers,
body.ui-hidden #help-modal {
  opacity: 0 !important;
  pointer-events: none !important;
}

@media (max-width: 1100px) {
  #left-panel { width: 230px; }
  #right-panel { width: 270px; }
}
