:root {
  color-scheme: dark;
  --cyan: #5deeff;
  --cyan-soft: #bafaff;
  --teal: #20e6c8;
  --green: #8cffb6;
  --gold: #ffd36a;
  --amber: #ff9f43;
  --rose: #ff6f8f;
  --violet: #a98bff;
  --ink: #f4fbff;
  --muted: #98abba;
  --panel: rgba(6, 18, 31, 0.58);
  --panel-strong: rgba(6, 18, 31, 0.82);
  --line: rgba(124, 232, 255, 0.24);
  --line-strong: rgba(124, 232, 255, 0.48);
  --shadow: 0 0 28px rgba(93, 238, 255, 0.2), 0 22px 80px rgba(0, 0, 0, 0.45);
  --font-display: 'Orbitron', system-ui, sans-serif;
  --font-ui: 'Rajdhani', system-ui, sans-serif;
  --font-mono: 'Share Tech Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }

#load-error {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(2, 8, 15, 0.86);
}

#load-error[hidden] { display: none; }

.load-error-card {
  max-width: 420px;
  padding: 24px 26px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--panel-strong);
  box-shadow: var(--shadow);
  color: var(--ink);
  font-family: var(--font-ui);
  text-align: center;
}

.load-error-card b {
  display: block;
  margin-bottom: 8px;
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--cyan);
}

.load-error-card p {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.load-error-card button {
  padding: 9px 22px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: rgba(93, 238, 255, 0.14);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 48% 35%, rgba(14, 47, 77, 0.92) 0%, rgba(3, 10, 18, 0.98) 58%, #01040a 100%),
    #01040a;
  color: var(--ink);
  font-family: var(--font-ui);
  letter-spacing: 0;
  -webkit-user-select: none;
  user-select: none;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

#scene {
  position: fixed;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}

#scene:active { cursor: grabbing; }

#screen-fx {
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

.grid-glow {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(rgba(93, 238, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(93, 238, 255, 0.035) 1px, transparent 1px);
  background-size: 54px 54px;
  -webkit-mask-image: radial-gradient(circle at 50% 42%, #000 0%, transparent 72%);
  mask-image: radial-gradient(circle at 50% 42%, #000 0%, transparent 72%);
  opacity: 0.55;
}

.scanlines {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(to bottom, rgba(93, 238, 255, 0.045) 0, rgba(93, 238, 255, 0.045) 1px, transparent 2px, transparent 4px);
  opacity: 0.42;
  mix-blend-mode: screen;
  animation: scan 9s linear infinite;
}

@keyframes scan { to { background-position-y: 180px; } }

.vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 48%, transparent 50%, rgba(0, 2, 8, 0.72) 100%);
}

.glass {
  background: linear-gradient(155deg, var(--panel), rgba(7, 25, 40, 0.4));
  border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(11px);
  backdrop-filter: blur(11px);
  box-shadow: var(--shadow), inset 0 0 28px rgba(93, 238, 255, 0.06);
}

.topbar {
  position: fixed;
  z-index: 12;
  top: 14px;
  left: 14px;
  right: 14px;
  min-height: 68px;
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) 230px;
  align-items: center;
  gap: 18px;
  padding: 12px 16px;
  clip-path: polygon(0 10px, 10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%);
}

.back-link {
  color: var(--cyan);
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

.back-link:hover { color: #fff; }

.brand { min-width: 0; }

.brand-kicker {
  display: block;
  font-family: var(--font-mono);
  color: var(--green);
  font-size: 12px;
  letter-spacing: 2px;
  text-transform: uppercase;
  opacity: 0.9;
}

.brand h1 {
  margin: 2px 0 0;
  color: #fff;
  font-family: var(--font-display);
  font-size: clamp(20px, 3vw, 31px);
  line-height: 1;
  letter-spacing: 2px;
  text-transform: uppercase;
  text-shadow: 0 0 18px rgba(93, 238, 255, 0.55);
}

.top-status {
  justify-self: end;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 1.4px;
  color: var(--cyan-soft);
  text-transform: uppercase;
}

.top-status b {
  display: block;
  margin-top: 4px;
  color: var(--gold);
  font-weight: 400;
}

.left-panel {
  position: fixed;
  z-index: 11;
  top: 96px;
  left: 14px;
  bottom: 58px;
  width: 306px;
  padding: 16px;
  overflow-y: auto;
  clip-path: polygon(0 12px, 12px 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%);
}

.panel-section + .panel-section {
  margin-top: 18px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(124, 232, 255, 0.18);
  color: var(--teal);
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.mode-row,
.filter-grid {
  display: grid;
  gap: 8px;
}

.mode-row { grid-template-columns: 1fr 1fr; }

.mode-row .reset-btn { grid-column: 1 / -1; }

.filter-grid { grid-template-columns: repeat(2, 1fr); }

.mode-btn,
.filter,
.reset-btn,
.part-item {
  border: 1px solid var(--line);
  background: rgba(93, 238, 255, 0.055);
  color: var(--cyan-soft);
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.mode-btn,
.filter,
.reset-btn {
  min-height: 36px;
  padding: 8px 10px;
  border-radius: 7px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.mode-btn:hover,
.filter:hover,
.reset-btn:hover,
.part-item:hover {
  border-color: var(--line-strong);
  background: rgba(93, 238, 255, 0.12);
  color: #fff;
}

.mode-btn.active,
.filter.active {
  border-color: rgba(140, 255, 182, 0.52);
  color: var(--green);
  background: rgba(140, 255, 182, 0.1);
}

.reset-btn {
  width: 100%;
  margin-top: 10px;
}

.part-section { padding-bottom: 6px; }

.part-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.part-item {
  width: 100%;
  display: grid;
  grid-template-columns: 10px 1fr auto;
  align-items: center;
  gap: 9px;
  padding: 8px 9px;
  border-radius: 7px;
  text-align: left;
}

.part-item i {
  width: 10px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--part-color);
  box-shadow: 0 0 12px var(--part-color);
}

.part-item span {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.part-item small {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.part-item.active {
  border-color: var(--part-color);
  background: rgba(93, 238, 255, 0.14);
}

.part-item.dimmed { display: none; }

#label-layer {
  position: fixed;
  inset: 0;
  z-index: 9;
  pointer-events: none;
}

.part-label {
  position: absolute;
  top: 0;
  left: 0;
  transform: translate(-50%, -50%);
  will-change: transform, opacity;
  backface-visibility: hidden;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 190px;
  min-height: 27px;
  padding: 5px 9px 5px 7px;
  border: 1px solid var(--part-color);
  border-radius: 7px;
  background: rgba(2, 10, 17, 0.74);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  white-space: nowrap;
  pointer-events: auto;
  cursor: pointer;
  box-shadow: 0 0 13px var(--part-color);
  transition: opacity 120ms ease, transform 120ms ease, background 120ms ease;
}

.part-label::before {
  content: "";
  width: 8px;
  aspect-ratio: 1;
  flex: none;
  border-radius: 50%;
  background: var(--part-color);
  box-shadow: 0 0 12px var(--part-color);
}

.part-label:hover,
.part-label.active {
  z-index: 4;
  background: rgba(10, 30, 44, 0.92);
  transform: translate(-50%, -50%) scale(1.05);
}

.part-label.hidden { display: none; }

.detail-panel {
  position: fixed;
  z-index: 13;
  top: 96px;
  right: 14px;
  bottom: 58px;
  width: min(426px, calc(100vw - 28px));
  padding: 20px 22px;
  overflow-y: auto;
  transform: translateX(calc(100% + 28px));
  opacity: 0;
  transition: transform 320ms cubic-bezier(0.22, 1, 0.36, 1), opacity 220ms ease;
  clip-path: polygon(0 12px, 12px 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%);
}

.detail-panel.open {
  transform: translateX(0);
  opacity: 1;
}

.detail-close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 34px;
  height: 34px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--cyan);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}

.detail-close:hover {
  border-color: var(--line);
  color: #fff;
  background: rgba(93, 238, 255, 0.08);
}

.detail-category {
  display: inline-flex;
  margin-bottom: 10px;
  padding: 4px 10px;
  border: 1px solid currentColor;
  border-radius: 6px;
  color: var(--green);
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.detail-panel h2 {
  margin: 0;
  padding-right: 34px;
  color: #fff;
  font-family: var(--font-display);
  font-size: 24px;
  line-height: 1.1;
  letter-spacing: 1px;
  text-shadow: 0 0 18px rgba(93, 238, 255, 0.45);
}

.detail-subtitle {
  margin: 8px 0 16px;
  color: var(--cyan-soft);
  font-size: 15px;
  line-height: 1.45;
}

.detail-block {
  margin: 0 0 14px;
  padding: 12px 13px;
  border: 1px solid rgba(124, 232, 255, 0.16);
  border-radius: 8px;
  background: rgba(93, 238, 255, 0.045);
}

.detail-block h3 {
  margin: 0 0 6px;
  color: var(--teal);
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.detail-block p,
.detail-block li {
  color: #d9eef5;
  font-size: 14px;
  line-height: 1.55;
}

.detail-block p { margin: 0; }

.detail-block ul {
  margin: 0;
  padding-left: 18px;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.meta-tile {
  border: 1px solid rgba(124, 232, 255, 0.16);
  border-radius: 8px;
  padding: 9px 10px;
  background: rgba(2, 10, 18, 0.36);
}

.meta-tile b {
  display: block;
  color: var(--gold);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.meta-tile span {
  display: block;
  margin-top: 3px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}

.detail-note {
  margin-top: 14px;
  color: rgba(217, 238, 245, 0.62);
  font-size: 11px;
  line-height: 1.45;
  font-style: italic;
}

.bottom-hint {
  position: fixed;
  z-index: 11;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: calc(100vw - 28px);
  padding: 8px 14px;
  border: 1px solid rgba(124, 232, 255, 0.18);
  border-radius: 8px;
  background: rgba(2, 10, 18, 0.54);
  color: var(--cyan-soft);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  white-space: nowrap;
}

.bottom-hint span + span::before {
  content: "/";
  margin-right: 14px;
  color: var(--gold);
}

@media (max-width: 980px) {
  .topbar {
    grid-template-columns: 1fr;
    gap: 6px;
    min-height: 92px;
  }

  .top-status {
    justify-self: start;
    text-align: left;
  }

  .left-panel {
    top: auto;
    right: 14px;
    bottom: 14px;
    width: auto;
    max-height: 235px;
    padding: 12px;
  }

  .part-section { display: none; }

  .filter-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }

  .detail-panel {
    top: 112px;
    bottom: 14px;
  }

  .bottom-hint { display: none; }
}

@media (max-width: 640px) {
  .brand h1 { font-size: 20px; }
  .brand-kicker { font-size: 10px; }
  .topbar { left: 10px; right: 10px; top: 10px; }
  .left-panel { left: 10px; right: 10px; bottom: 10px; }
  .detail-panel { right: 10px; width: calc(100vw - 20px); }
  .filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mode-row { grid-template-columns: 1fr; }
  .part-label { max-width: 142px; font-size: 9px; padding: 4px 6px; }
  .meta-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
