:root {
  --bg: #07080f;
  --ink: #f4f6ff;
  --muted: #9aa6d0;
  --line: rgba(255, 255, 255, 0.12);
  --accent: #8ec5ff;
  --paper: #d7dce8;
  --paper-ink: #1b2233;
  --shadow: 0 28px 60px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Sans SC", system-ui, sans-serif;
}

code, .path {
  font-family: "JetBrains Mono", ui-monospace, monospace;
}

.studio {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse 70% 50% at 15% 0%, #24315c 0%, transparent 55%),
    radial-gradient(ellipse 50% 40% at 90% 10%, #3a1d4a 0%, transparent 50%),
    radial-gradient(ellipse 60% 50% at 50% 100%, #10243a 0%, transparent 55%),
    #07080f;
}

.vignette {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(0, 0, 0, 0.55) 100%);
}

.top, .toolbar, .viewport, .legend, .foot, .drawer, .noscript {
  position: relative;
  z-index: 2;
}

.top {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 1rem 1.6rem 0.35rem;
}

.top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.hub, .foot a {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.92rem;
}

.hub:hover, .foot a:hover { text-decoration: underline; }

.eyebrow {
  margin: 0 0 0.25rem;
  color: var(--accent);
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  letter-spacing: -0.04em;
}

.lede {
  margin: 0.45rem 0 0;
  max-width: 46rem;
  color: var(--muted);
  line-height: 1.55;
}

.path {
  color: var(--muted);
  font-size: 0.78rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.9rem 1.6rem 0.2rem;
}

.filters, .tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.toolbar button {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.38rem 0.8rem;
  cursor: pointer;
  font: inherit;
  font-size: 0.85rem;
  flex-shrink: 0;
  min-height: 2rem;
}

.toolbar button.is-on,
.toolbar button:hover {
  border-color: var(--accent);
  background: rgba(142, 197, 255, 0.12);
}

.hint-inline {
  color: var(--muted);
  font-size: 0.8rem;
  margin-left: 0.4rem;
}

.viewport {
  position: relative;
  height: auto;
  min-height: 0;
  perspective: 1600px;
  overflow: visible;
  cursor: grab;
  touch-action: pan-y;
  padding: 1.2rem 0 2.4rem;
}

.viewport.is-drag { cursor: grabbing; }

.stage {
  height: auto;
  display: grid;
  place-items: center;
  transform-style: preserve-3d;
  padding: 1.4rem 0 2.6rem;
}

.board {
  display: grid;
  grid-template-columns: repeat(4, 158px);
  gap: 18px 14px;
  transform-style: preserve-3d;
  transform: rotateX(10deg) rotateY(-10deg);
  transition: transform 80ms linear;
  transform-origin: center 42%;
}

.floor {
  position: absolute;
  inset: auto 8% 6% 8%;
  height: 90px;
  background: radial-gradient(ellipse at center, rgba(142, 197, 255, 0.16), transparent 70%);
  filter: blur(18px);
  pointer-events: none;
}

.card {
  width: 158px;
  height: 236px;
  position: relative;
  transform-style: preserve-3d;
  transform: translateZ(0);
  transition: transform 220ms ease, opacity 220ms ease, filter 220ms ease;
}

.card.is-hidden {
  display: none;
}

.card:hover,
.card:focus-visible {
  transform: translateZ(48px) rotateX(-4deg);
  outline: none;
}

.card-body {
  position: absolute;
  inset: 0;
  border-radius: 18px;
  background:
    linear-gradient(180deg, #eef1f7 0%, var(--paper) 100%);
  color: var(--paper-ink);
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.4);
  padding: 0.7rem 0.65rem 0.6rem;
  transform: translateZ(10px);
  overflow: hidden;
}

.card-side,
.card-bottom {
  position: absolute;
  background: #8f97a8;
}

.card-side {
  top: 8px;
  right: -9px;
  width: 10px;
  height: calc(100% - 10px);
  transform: rotateY(90deg);
  transform-origin: left center;
  border-radius: 0 8px 8px 0;
}

.card-bottom {
  left: 8px;
  bottom: -8px;
  width: calc(100% - 8px);
  height: 10px;
  transform: rotateX(90deg);
  transform-origin: top center;
  border-radius: 0 0 8px 8px;
}

.card-name {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.card-meta {
  margin: 0.12rem 0 0.45rem;
  font-size: 0.62rem;
  color: #5b6478;
}

.arch {
  position: relative;
  height: 158px;
  transform-style: preserve-3d;
  border-radius: 14px;
  background: var(--tint, #c5d4e8);
  padding: 8px 8px 8px 10px;
}

.arch::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 99px;
  background: linear-gradient(180deg, #fff 0%, rgba(255,255,255,0.15) 100%);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.7);
}

.plates {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transform-style: preserve-3d;
}

.plate {
  position: relative;
  border-radius: 7px;
  padding: 0.18rem 0.35rem;
  font-size: 0.58rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
  transform: translateZ(8px);
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.18);
  transition: transform 220ms ease;
}

.card:hover .plate { transform: translateZ(22px) translateX(2px); }

.plate.embed { background: #4d5d78; }
.plate.pos { background: #6a7c99; }
.plate.norm { background: #2f3544; }
.plate.attn { background: #1f6feb; }
.plate.ffn { background: #0f766e; }
.plate.moe { background: #c2410c; }
.plate.head { background: #4338ca; }
.plate.repeat {
  background: transparent;
  color: var(--paper-ink);
  text-shadow: none;
  box-shadow: none;
  font-weight: 500;
  padding: 0;
}

.moe-fan {
  position: absolute;
  right: -6px;
  top: 42%;
  width: 34px;
  height: 34px;
  transform: translateZ(18px) rotateZ(45deg);
}

.moe-fan span {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: #ea580c;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.2);
}

.moe-fan span:nth-child(1) { top: 0; left: 11px; }
.moe-fan span:nth-child(2) { top: 11px; left: 0; background: #f59e0b; }
.moe-fan span:nth-child(3) { top: 11px; left: 22px; background: #fb7185; }
.moe-fan span:nth-child(4) { top: 22px; left: 11px; background: #22c55e; }

.drawer {
  position: fixed;
  inset: auto 1rem 1rem 1rem;
  max-width: 1080px;
  margin: 0 auto;
  background: rgba(12, 16, 28, 0.92);
  border: 1px solid var(--line);
  border-radius: 22px;
  backdrop-filter: blur(16px);
  padding: 1.1rem 1.2rem 1.2rem;
  box-shadow: var(--shadow);
  z-index: 5;
}

.drawer[hidden] { display: none; }

.close {
  position: absolute;
  top: 0.8rem;
  right: 0.9rem;
  appearance: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
  cursor: pointer;
  font: inherit;
}

.drawer-grid {
  display: grid;
  grid-template-columns: minmax(240px, 320px) 1fr;
  gap: 1.4rem;
  align-items: center;
}

.explode-wrap {
  min-height: 280px;
  perspective: 900px;
}

.explode-kicker {
  margin: 0 0 0.6rem;
  color: var(--accent);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
}

.explode {
  position: relative;
  height: 260px;
  transform-style: preserve-3d;
  transform: rotateX(12deg) rotateY(-24deg);
}

.explode .spine {
  position: absolute;
  left: 24px;
  top: 8px;
  bottom: 8px;
  width: 4px;
  border-radius: 99px;
  background: linear-gradient(180deg, #fff, var(--accent));
  box-shadow: 0 0 18px var(--accent);
}

.explode .layer {
  position: absolute;
  left: 42px;
  right: 12px;
  height: 28px;
  border-radius: 8px;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  padding: 0 0.7rem;
  box-shadow: 8px 10px 0 rgba(0, 0, 0, 0.25);
}

.fact-tag {
  margin: 0;
  color: var(--accent);
  font-size: 0.78rem;
}

.facts h2 {
  margin: 0.2rem 0 0.5rem;
  font-size: 1.5rem;
}

.fact-summary {
  margin: 0 0 0.9rem;
  color: var(--muted);
  line-height: 1.55;
}

.spec {
  display: grid;
  grid-template-columns: 6.2rem 1fr;
  gap: 0.35rem 0.8rem;
  margin: 0 0 0.8rem;
  font-size: 0.92rem;
}

.spec dt { color: var(--muted); }
.spec dd { margin: 0; }

.bullets {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--ink);
  line-height: 1.55;
}

.legend {
  padding: 0.4rem 1.6rem 0.2rem;
}

.legend h2 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
}

.legend ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem 1.2rem;
  list-style: none;
  padding: 0;
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.swatch {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 3px;
  margin-right: 0.35rem;
  vertical-align: -1px;
}

.swatch.embed { background: #4d5d78; }
.swatch.norm { background: #2f3544; }
.swatch.attn { background: #1f6feb; }
.swatch.ffn { background: #0f766e; }
.swatch.head { background: #4338ca; }

.foot {
  padding: 1.2rem 1.6rem 2rem;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.55;
}

.noscript {
  padding: 1rem 1.6rem;
  color: #fca5a5;
}

@media (max-width: 900px) {
  .board { grid-template-columns: repeat(3, 150px); gap: 16px; }
  .card { width: 150px; }
  .drawer-grid { grid-template-columns: 1fr; }
  .hint-inline { display: none; }
}

@media (max-width: 640px) {
  .viewport { cursor: default; touch-action: auto; padding: 0.4rem 0 1.2rem; }
  .board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: min(420px, calc(100% - 1.4rem));
    transform: none !important;
    padding: 0.5rem 0 1rem;
    gap: 12px;
  }
  .card { width: auto; height: 222px; }
  .card-side, .card-bottom { display: none; }
  .drawer {
    inset: auto 0 0 0;
    max-height: 78vh;
    overflow: auto;
    border-radius: 22px 22px 0 0;
    margin: 0;
  }
  .explode-wrap { min-height: 200px; }
  .explode { height: 210px; }
  .spec { grid-template-columns: 1fr; }
  .spec dt { font-size: 0.78rem; }
}

@media (prefers-reduced-motion: reduce) {
  .board, .card, .plate { transition: none; }
  .viewport { cursor: default; }
}
