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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  color: #dfe7f5;
  font-family: "Avenir Next", "Helvetica Neue", "Hiragino Sans", "Hiragino Kaku Gothic ProN", sans-serif;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
}

#view {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
#view:active { cursor: grabbing; }

/* ---------- title ---------- */
#title {
  position: fixed;
  top: 26px;
  left: 32px;
  pointer-events: none;
  z-index: 5;
}
#title h1 {
  font-size: 26px;
  font-weight: 300;
  letter-spacing: 0.55em;
  color: #f2f6ff;
  text-shadow: 0 0 24px rgba(120, 170, 255, 0.45);
}
#title .sub {
  margin-top: 6px;
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.28em;
  color: rgba(200, 216, 245, 0.62);
}
#desc {
  margin-top: 14px;
  font-size: 12.5px;
  letter-spacing: 0.12em;
  color: rgba(170, 195, 235, 0.85);
  transition: opacity 0.3s ease;
}

/* ---------- HUD ---------- */
#hud {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 14px 18px;
  max-width: min(94vw, 720px);
  padding: 16px 26px 14px;
  border-radius: 18px;
  background: rgba(10, 15, 28, 0.55);
  border: 1px solid rgba(150, 180, 255, 0.14);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(16px) saturate(1.3);
  -webkit-backdrop-filter: blur(16px) saturate(1.3);
}

.divider {
  width: 1px;
  height: 44px;
  background: linear-gradient(to bottom, transparent, rgba(160, 190, 255, 0.25), transparent);
}

/* scale slider */
.scale-block { display: flex; flex-direction: column; gap: 8px; }

.scale-labels {
  display: flex;
  justify-content: space-between;
  width: 300px;
}
.scale-label {
  appearance: none;
  background: none;
  border: 0;
  font: inherit;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: rgba(150, 172, 210, 0.5);
  cursor: pointer;
  transition: color 0.25s, text-shadow 0.25s;
  padding: 2px 0;
}
.scale-label:first-child { text-align: left; }
.scale-label:last-child { text-align: right; }
.scale-label.active {
  color: #cfe0ff;
  text-shadow: 0 0 14px rgba(120, 170, 255, 0.8);
}

.slider-row { position: relative; width: 300px; height: 22px; }

.ticks {
  position: absolute;
  top: 50%;
  left: 9px;
  right: 9px;
  transform: translateY(-50%);
  display: flex;
  justify-content: space-between;
  pointer-events: none;
}
.ticks i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(170, 200, 255, 0.35);
}

#scale-slider {
  position: absolute;
  inset: 0;
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  cursor: pointer;
  z-index: 2;
}
#scale-slider::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(90deg, rgba(90, 140, 255, 0.55), rgba(150, 110, 255, 0.45));
  box-shadow: 0 0 10px rgba(100, 150, 255, 0.35);
}
#scale-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -7.5px;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, #ffffff, #a8c8ff 55%, #5f8fe8);
  box-shadow: 0 0 16px rgba(140, 180, 255, 0.95), 0 0 4px rgba(255, 255, 255, 0.9);
  border: 0;
  transition: transform 0.15s;
}
#scale-slider::-webkit-slider-thumb:hover { transform: scale(1.15); }
#scale-slider::-moz-range-track {
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(90deg, rgba(90, 140, 255, 0.55), rgba(150, 110, 255, 0.45));
}
#scale-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 0;
  background: radial-gradient(circle at 38% 32%, #ffffff, #a8c8ff 55%, #5f8fe8);
  box-shadow: 0 0 16px rgba(140, 180, 255, 0.95);
}

/* deform toggle */
.toggle[hidden] { display: none; }
.flip-i { display: inline-block; transform: scaleX(-1); }
.toggle {
  appearance: none;
  background: none;
  border: 0;
  font: inherit;
  display: flex;
  align-items: center;
  gap: 11px;
  cursor: pointer;
  padding: 4px 2px;
}
.toggle .pill {
  position: relative;
  width: 46px;
  height: 24px;
  border-radius: 13px;
  background: rgba(70, 85, 120, 0.45);
  border: 1px solid rgba(160, 190, 255, 0.2);
  transition: background 0.3s, box-shadow 0.3s;
}
.toggle .knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(160deg, #e8eefc, #9db4dd);
  transition: transform 0.3s cubic-bezier(0.34, 1.4, 0.5, 1), background 0.3s;
}
.toggle[aria-pressed="true"] .pill {
  background: linear-gradient(90deg, rgba(90, 150, 255, 0.75), rgba(160, 110, 255, 0.7));
  box-shadow: 0 0 18px rgba(120, 160, 255, 0.55);
}
.toggle[aria-pressed="true"] .knob {
  transform: translateX(22px);
  background: #ffffff;
}
.toggle .t-label {
  font-size: 12.5px;
  letter-spacing: 0.22em;
  color: rgba(190, 208, 240, 0.85);
  transition: color 0.3s, text-shadow 0.3s;
  white-space: nowrap;
}
.toggle[aria-pressed="true"] .t-label {
  color: #e8f0ff;
  text-shadow: 0 0 12px rgba(140, 180, 255, 0.8);
}

/* fullscreen icon button */
.icon-btn {
  appearance: none;
  border: 1px solid rgba(160, 190, 255, 0.2);
  background: rgba(70, 85, 120, 0.4);
  border-radius: 10px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: rgba(200, 216, 245, 0.85);
  transition: background 0.25s, box-shadow 0.25s, color 0.25s;
}
.icon-btn:hover {
  background: rgba(95, 115, 160, 0.55);
  color: #fff;
  box-shadow: 0 0 14px rgba(120, 160, 255, 0.35);
}
.icon-btn svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-btn .ic-compress { display: none; }
html.is-fs .icon-btn .ic-expand { display: none; }
html.is-fs .icon-btn .ic-compress { display: block; }

/* discreet link back to the site index */
#up {
  position: fixed;
  top: 28px;
  right: 30px;
  z-index: 6;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.32em;
  text-decoration: none;
  color: rgba(170, 195, 235, 0.42);
  padding: 6px 4px 6px 8px;
  transition: color 0.25s, text-shadow 0.25s;
}
#up:hover {
  color: rgba(220, 233, 255, 0.95);
  text-shadow: 0 0 12px rgba(130, 170, 255, 0.7);
}

/* ---------- misc ---------- */
#credit {
  position: fixed;
  right: 14px;
  bottom: 10px;
  font-size: 9.5px;
  letter-spacing: 0.08em;
  color: rgba(140, 160, 200, 0.4);
  z-index: 5;
  pointer-events: none;
}

#fade {
  position: fixed;
  inset: 0;
  background: #000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
  z-index: 20;
}
#fade.on { opacity: 1; }

#loading {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.7s ease;
}
#loading.done { opacity: 0; pointer-events: none; }
.l-inner { text-align: center; }
.l-title {
  font-size: 30px;
  font-weight: 200;
  letter-spacing: 0.65em;
  margin-left: 0.65em;
  color: #eef3ff;
  text-shadow: 0 0 30px rgba(130, 175, 255, 0.7);
  animation: breathe 2.4s ease-in-out infinite;
}
@keyframes breathe {
  0%, 100% { opacity: 0.65; }
  50% { opacity: 1; }
}
.l-bar {
  width: 220px;
  height: 2px;
  margin: 26px auto 14px;
  background: rgba(120, 150, 210, 0.18);
  border-radius: 1px;
  overflow: hidden;
}
.l-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #6f9fff, #b48aff);
  box-shadow: 0 0 12px rgba(130, 165, 255, 0.9);
  transition: width 0.25s ease;
}
.l-note {
  font-size: 10.5px;
  letter-spacing: 0.3em;
  color: rgba(160, 180, 220, 0.55);
}

@media (max-width: 640px) {
  #hud { gap: 14px; padding: 12px 16px 10px; bottom: 16px; }
  .scale-labels, .slider-row { width: 220px; }
  #title { top: 16px; left: 18px; }
  #title h1 { font-size: 20px; }
}

/* ---------- 探査機ミッション (浮遊メニュー) ---------- */
#missions {
  position: fixed;
  right: 22px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 12;
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
  gap: 12px;
  transition: opacity 0.5s ease;
}
#missions { pointer-events: none; }   /* 透明なコンテナ箱がHUDのタップを食わないように */
#missions.m-hidden { opacity: 0; }
#m-toggle {
  pointer-events: auto;
  appearance: none;
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  padding: 13px 10px 11px;
  background: rgba(10, 15, 28, 0.55);
  border: 1px solid rgba(150, 180, 255, 0.16);
  border-radius: 14px;
  color: rgba(170, 195, 235, 0.75);
  cursor: pointer;
  backdrop-filter: blur(14px) saturate(1.3);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  transition: color 0.25s, border-color 0.25s, box-shadow 0.25s;
}
#m-toggle:hover { color: #dfeaff; border-color: rgba(150, 190, 255, 0.45); }
#m-toggle.running {
  color: #cfe4ff;
  border-color: rgba(140, 190, 255, 0.55);
  box-shadow: 0 0 18px rgba(110, 160, 255, 0.35), 0 8px 30px rgba(0, 0, 0, 0.45);
}
#m-toggle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linejoin: round; }
#m-toggle .en {
  font-size: 9px; font-weight: 500; letter-spacing: 0.24em;
  writing-mode: vertical-rl; text-orientation: mixed;
}
#m-panel {
  width: 288px;
  max-height: min(70vh, 560px);
  overflow-y: auto;
  padding: 12px;
  background: rgba(9, 14, 27, 0.72);
  border: 1px solid rgba(150, 180, 255, 0.16);
  border-radius: 16px;
  backdrop-filter: blur(18px) saturate(1.35);
  -webkit-backdrop-filter: blur(18px) saturate(1.35);
  box-shadow: 0 14px 50px rgba(0, 0, 0, 0.55);
  opacity: 0;
  transform: translateX(10px);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
#missions.open #m-panel { opacity: 1; transform: none; pointer-events: auto; }
.m-head {
  padding: 4px 8px 10px;
  font-size: 10px; font-weight: 500; letter-spacing: 0.22em;
  color: rgba(150, 175, 215, 0.6);
  border-bottom: 1px solid rgba(150, 180, 255, 0.1);
  margin-bottom: 6px;
}
.m-item {
  appearance: none; display: block; width: 100%;
  text-align: left;
  background: none; border: 0;
  border-radius: 10px;
  padding: 9px 10px 10px;
  cursor: pointer;
  color: inherit;
  transition: background 0.2s;
}
.m-item:hover { background: rgba(120, 170, 255, 0.08); }
.m-item.active { background: rgba(120, 170, 255, 0.14); box-shadow: inset 0 0 0 1px rgba(140, 190, 255, 0.35); }
.m-item strong {
  font-size: 12.5px; font-weight: 600; letter-spacing: 0.14em;
  color: rgba(220, 234, 255, 0.95);
}
.m-item em {
  float: right;
  font-style: normal;
  font-size: 10px;
  color: rgba(150, 175, 215, 0.6);
  letter-spacing: 0.06em;
  margin-top: 2px;
}
.m-item span {
  display: block; margin-top: 3px;
  font-size: 10.5px; line-height: 1.5;
  color: rgba(175, 198, 232, 0.62);
}
@media (max-width: 760px) {
  #missions { right: 10px; }
  #m-panel { width: min(260px, 72vw); }
}

/* ---------- タッチ端末: レベル操作をしやすく ---------- */
#hud-tab {
  display: none;
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 10px;
  z-index: 11;
  width: 68px;
  height: 26px;
  border-radius: 999px;
  border: 1px solid rgba(150, 180, 255, 0.2);
  background: rgba(10, 15, 28, 0.55);
  backdrop-filter: blur(10px) saturate(1.2);
  -webkit-backdrop-filter: blur(10px) saturate(1.2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s;
  cursor: pointer;
  touch-action: manipulation;
}
#hud-tab::before {
  content: '';
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 26px; height: 3px;
  border-radius: 2px;
  background: rgba(180, 200, 240, 0.65);
}
#hud-tab.shown { opacity: 1; pointer-events: auto; }

@media (pointer: coarse) {
  #hud { touch-action: manipulation; }
  .slider-row { height: 34px; }
  #scale-slider { height: 34px; }
  #scale-slider::-webkit-slider-thumb { width: 28px; height: 28px; margin-top: -12px; }
  #scale-slider::-moz-range-thumb { width: 28px; height: 28px; }
  .scale-label { padding: 11px 10px; font-size: 12px; touch-action: manipulation; }
  /* HUDドロワー (スマホのみ): しまうと下端のグラバーだけ残る */
  #hud { transition: transform 0.45s cubic-bezier(0.33, 0, 0.2, 1); }
  #hud.stowed { transform: translateX(-50%) translateY(calc(100% + 40px)); }
  #hud-tab { display: block; }
  .toggle .pill { transform: scale(1.15); }
}

/* ---------- 右肩: 歯車と設定パネル ---------- */
#gear {
  position: fixed;
  top: 23px;
  right: 138px;
  z-index: 6;
  width: 32px;
  height: 32px;
  padding: 6px;
  border: 0;
  background: none;
  cursor: pointer;
  color: rgba(170, 195, 235, 0.42);
  transition: color 0.25s, transform 0.45s;
}
#gear:hover { color: rgba(215, 232, 255, 0.92); transform: rotate(40deg); }
#gear svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round; }
#settings {
  position: fixed;
  top: 60px;
  right: 26px;
  z-index: 7;
  min-width: 232px;
  padding: 12px 14px 10px;
  background: rgba(9, 15, 28, 0.86);
  border: 1px solid rgba(150, 190, 255, 0.16);
  border-radius: 11px;
  backdrop-filter: blur(16px) saturate(130%);
  -webkit-backdrop-filter: blur(16px) saturate(130%);
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}
#settings[hidden] { display: none; }
#settings .s-head {
  font-size: 9.5px;
  letter-spacing: 0.32em;
  color: rgba(170, 195, 235, 0.5);
  margin: 0 2px 8px;
}
#settings .toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 2px;
  background: none;
  border: 0;
  cursor: pointer;
}

/* ---------- ミッションのカテゴリ・アコーディオン ---------- */
#m-panel { max-height: min(68vh, 640px); overflow-y: auto; overscroll-behavior: contain; }
.m-cat { border-top: 1px solid rgba(150, 190, 255, 0.09); }
.m-cat-head {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 13px;
  background: none;
  border: 0;
  cursor: pointer;
  color: rgba(195, 214, 244, 0.88);
  font-size: 11.5px;
  letter-spacing: 0.12em;
  font-weight: 600;
}
.m-cat-head:hover { background: rgba(120, 170, 255, 0.07); }
.m-cat-head .n {
  margin-left: auto;
  font-style: normal;
  opacity: 0.42;
  font-size: 10px;
  letter-spacing: 0;
}
.m-cat-head .chev {
  width: 7px;
  height: 7px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg) translateY(-1px);
  transition: transform 0.22s;
  opacity: 0.6;
}
.m-cat.open .m-cat-head .chev { transform: rotate(45deg); }
.m-cat-body { display: none; }
.m-cat.open .m-cat-body { display: block; }
.m-item .lv {
  font-style: normal;
  font-size: 8.5px;
  letter-spacing: 0.1em;
  opacity: 0.55;
  margin-left: 8px;
  padding: 0 4px 1px;
  border: 1px solid rgba(170, 200, 255, 0.32);
  border-radius: 3px;
}
@media (max-width: 600px) {
  #gear { right: 122px; top: 21px; }
  #m-panel { max-height: min(58vh, 520px); }
}
