:root {
  color-scheme: dark;
  --bg: #08070d;
  --surface-1: #121018;
  --surface-2: #1b1723;
  --surface-3: #282132;
  --border: #352c42;
  --text: #fff;
  --secondary: #b9b2c4;
  --muted: #83798f;
  --luna: #a66cff;
  --luna-bright: #c69cff;
  --blue: #695cff;
  --pink: #dd55cf;
  --cyan: #43c6da;
  --radius: 7px;
}

* { box-sizing: border-box; }
html { max-width: 100%; overflow-x: clip; scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 0;
  max-width: 100%;
  overflow-x: clip;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "Helvetica Neue", Helvetica, Arial, sans-serif;
}
a { color: var(--luna-bright); }
button, input, select { font: inherit; }
.hidden { display: none !important; }

.ambient {
  position: absolute;
  z-index: 0;
  top: 56px;
  left: 0;
  right: 0;
  height: min(760px, 82vh);
  overflow: hidden;
  pointer-events: none;
  opacity: .58;
  mask-image: linear-gradient(#000 0 58%, transparent 100%);
}
.ambient::before {
  content: "";
  position: absolute;
  width: 60vw;
  height: 60vw;
  min-width: 620px;
  min-height: 620px;
  right: -24vw;
  top: -42vw;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(177,104,255,.23), rgba(93,43,160,.07) 42%, transparent 70%);
  animation: glow 12s ease-in-out infinite alternate;
}
.ambient i {
  position: absolute;
  top: -15%;
  right: -16%;
  width: 82%;
  height: 24%;
  border-radius: 100%;
  background: linear-gradient(90deg, transparent, rgba(177,104,255,.07), rgba(213,156,255,.18), transparent 72%);
  filter: blur(12px);
  transform: rotate(-26deg);
  transform-origin: right center;
  animation: ray 11s ease-in-out infinite alternate;
}
.ambient i:nth-child(2) { top: 8%; width: 66%; opacity: .7; animation-delay: -4s; transform: rotate(-19deg); }
.ambient i:nth-child(3) { top: 29%; width: 54%; opacity: .46; animation-delay: -8s; transform: rotate(-13deg); }
@keyframes glow { to { opacity: .72; transform: translate(-3%, 3%) scale(1.06); } }
@keyframes ray { to { opacity: .45; transform: rotate(-20deg) translateY(16px); } }
@media (prefers-reduced-motion: reduce) { .ambient::before, .ambient i { animation: none; } }

.topnav {
  position: sticky;
  z-index: 50;
  top: 0;
  height: 56px;
  padding: 0 32px;
  display: flex;
  align-items: center;
  gap: 26px;
  background: rgba(8,7,13,.94);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(14px);
}
.wordmark { display: inline-flex; align-items: center; gap: 10px; flex: none; text-decoration: none; }
.luna-logo { display: block; width: 86px; height: 26px; object-fit: contain; }
.research-label { color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .1em; white-space: nowrap; }
.topnav nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.topnav nav::-webkit-scrollbar { display: none; }
.nav-tab {
  flex: none;
  padding: 7px 13px;
  border: 0;
  border-radius: 999px;
  color: var(--secondary);
  background: transparent;
  cursor: pointer;
  white-space: nowrap;
  font-size: 14px;
  text-decoration: none;
}
.nav-tab:hover { color: #fff; background: var(--surface-2); }
.nav-tab.active { color: #fff; background: var(--surface-3); font-weight: 600; }
.homelink {
  margin-left: auto;
  color: #fff;
  font-size: 12px;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  padding: 7px 11px;
  border: 1px solid rgba(255,255,255,.7);
  border-radius: 999px;
}
.homelink:hover { background: rgba(255,255,255,.1); border-color: #fff; }

.pagehead {
  position: relative;
  z-index: 1;
  padding: 30px 32px 21px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(39,17,64,.72), rgba(8,7,13,.25));
}
.eyebrow { margin: 0 0 5px !important; color: var(--luna-bright) !important; font-size: 11px !important; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; }
.pagehead h1 { margin: 0 0 7px; font-size: 30px; line-height: 1.15; letter-spacing: -.025em; }
.pagehead p { max-width: 92ch; margin: 0; color: var(--secondary); font-size: 14px; }
main { position: relative; z-index: 1; max-width: 1600px; margin: 0 auto; padding: 24px 32px 64px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.section-block { margin: 0 0 36px; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 18px; margin-bottom: 13px; }
.section-title h2 { margin: 0; font-size: 17px; font-weight: 650; }
.section-title span { color: var(--muted); font-size: 11px; }

.tiles, .charts {
  display: flex;
  flex-wrap: nowrap;
  gap: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0 0 11px;
  margin: 0 0 28px;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
  scrollbar-color: var(--surface-3) transparent;
}
.charts { gap: 16px; margin-bottom: 0; }
.tiles::-webkit-scrollbar, .charts::-webkit-scrollbar { height: 8px; }
.tiles::-webkit-scrollbar-thumb, .charts::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 99px; }
.tile, .chart-card { background: rgba(18,16,24,.94); border: 1px solid var(--border); border-radius: var(--radius); scroll-snap-align: start; }
.tile { flex: 0 0 clamp(168px, 17vw, 220px); padding: 14px 16px; }
.tile .number { font-size: 30px; font-weight: 750; line-height: 1.1; letter-spacing: -.03em; }
.tile .label { color: var(--secondary); font-size: 12px; margin-top: 3px; }
.chart-card { flex: 0 0 clamp(320px, 31vw, 440px); min-height: 238px; padding: 17px 18px; }
.chart-card h3 { margin: 0 0 3px; font-size: 14px; }
.chart-card .caption { min-height: 36px; margin: 0 0 15px; color: var(--muted); font-size: 12px; }
.chart-empty { display: grid; place-items: center; min-height: 125px; border: 1px dashed var(--border); border-radius: 5px; color: var(--muted); font-size: 12px; text-align: center; }
.bar-list { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: minmax(80px, 32%) 1fr auto; align-items: center; gap: 9px; font-size: 12px; }
.bar-label { color: var(--secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 11px; overflow: hidden; background: var(--surface-3); border-radius: 2px; }
.bar-fill { display: block; height: 100%; min-width: 2px; background: linear-gradient(90deg, var(--blue), var(--luna)); }

.toolbar {
  position: sticky;
  z-index: 20;
  top: 56px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px;
  margin-bottom: 16px;
  padding: 13px 15px;
  background: rgba(18,16,24,.96);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(10px);
}
input[type="search"], select {
  min-width: 148px;
  padding: 8px 10px;
  color: #fff;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 13px;
}
input[type="search"] { min-width: 235px; }
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--luna); outline-offset: 2px; }
.sort-label { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .07em; }
.reset, .view-toggle button { padding: 8px 12px; color: var(--secondary); background: var(--surface-2); border: 1px solid var(--border); cursor: pointer; }
.reset { border-radius: 5px; }
.reset:hover, .view-toggle button:hover { color: #fff; background: var(--surface-3); }
.view-toggle { display: flex; overflow: hidden; border: 1px solid var(--border); border-radius: 5px; }
.view-toggle button { border: 0; }
.view-toggle button[aria-pressed="true"] { color: #fff; background: var(--luna); }
.count { margin-left: auto; color: var(--secondary); font-size: 13px; }

.game-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.game-card { overflow: hidden; display: flex; flex-direction: column; min-height: 260px; color: inherit; text-decoration: none; background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); transition: transform .15s, border-color .15s; }
.game-card:hover { transform: translateY(-3px); border-color: #604f75; }
.game-art { aspect-ratio: 16/9; background: linear-gradient(135deg, #261c36, #121018); overflow: hidden; }
.game-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.game-meta { display: flex; flex: 1; flex-direction: column; gap: 5px; padding: 11px 12px 13px; }
.game-meta h3 { margin: 0; font-size: 14px; line-height: 1.3; }
.game-meta p { margin: 0; color: var(--muted); font-size: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: auto; padding-top: 7px; }
.chip { padding: 2px 7px; border-radius: 99px; color: #cfbfdd; background: #292134; font-size: 10.5px; }
.chip.access { color: #eee5ff; background: #39245a; }
.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { color: var(--secondary); background: var(--surface-2); font-size: 12px; white-space: nowrap; }
tbody tr:hover { background: var(--surface-1); }

.directory-grid, .feature-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 15px; }
.directory-card, .feature-card { padding: 17px; background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); }
.directory-card h3, .feature-card h3 { margin: 0 0 5px; font-size: 15px; }
.directory-card p, .feature-card p { margin: 0; color: var(--secondary); font-size: 12.5px; }
.source-link { display: inline-block; margin-top: 11px; font-size: 11px; }
.muted { color: var(--muted); }

/* Studio research */
.map-card { padding: 0; overflow: hidden; position: relative; background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); }
.map-bar { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.map-bar h3 { margin: 0; font-size: 14px; }
.map-bar p { margin: 1px 0 0; color: var(--muted); font-size: 12px; }
.map-zoom { margin-left: auto; display: flex; gap: 6px; }
.map-zoom button { min-width: 30px; height: 30px; padding: 0 10px; color: var(--primary); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; font: inherit; font-size: 12px; }
.map-zoom button:hover { background: var(--surface-3); }
.map-viewport { position: relative; height: 560px; overflow: hidden; background: #100c19; cursor: grab; }
.map-viewport.dragging { cursor: grabbing; }
.map-viewport svg { width: 100%; height: 100%; display: block; touch-action: none; }
.country { fill: #211a2d; stroke: #382b4c; stroke-width: .4; vector-effect: non-scaling-stroke; }
.country.has-studios { fill: #372653; }
.pin { cursor: pointer; }
.pin .halo { fill: rgba(8,7,13,.82); stroke: var(--luna-bright); stroke-width: 1.7; vector-effect: non-scaling-stroke; }
.pin:hover .halo, .pin.active .halo { stroke: #fff; stroke-width: 2.5; }
.pin .badge-bg { fill: var(--luna); }
.pin .badge-tx { fill: #fff; font-size: 9px; font-weight: 700; text-anchor: middle; font-family: inherit; }
.map-tip { position: absolute; z-index: 5; max-width: 270px; padding: 7px 10px; pointer-events: none; color: var(--primary); background: rgba(8,7,13,.97); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 7px 22px rgba(0,0,0,.6); font-size: 12px; }
.map-tip .sub { color: var(--muted); font-size: 11px; }
.map-pop { position: absolute; z-index: 6; min-width: 220px; max-width: 310px; max-height: 320px; overflow: auto; padding: 10px 12px; color: var(--primary); background: var(--surface-1); border: 1px solid #5f4a78; border-radius: var(--radius); box-shadow: 0 10px 30px rgba(0,0,0,.7); }
.map-pop h4 { margin: 0 0 8px; color: var(--muted); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }
.map-pop a { display: block; padding: 5px 0; color: var(--primary); text-decoration: none; }
.map-pop a:hover { color: var(--luna-bright); }
.map-legend { display: flex; flex-wrap: wrap; gap: 16px; padding: 10px 16px; color: var(--muted); border-top: 1px solid var(--border); font-size: 11px; }
.studio-name { display: flex; align-items: center; gap: 9px; }
.studio-mark { display: grid; place-items: center; flex: none; width: 34px; height: 34px; color: var(--secondary); background: var(--surface-3); border-radius: 7px; font-size: 12px; font-weight: 750; }
.studio-name a { color: var(--primary); font-weight: 650; text-decoration: none; }
.studio-name a:hover { color: var(--luna-bright); }
.studio-table-wrap { max-height: none; }
.studio-table-wrap td { vertical-align: top; }
.detail-grid { display: grid; grid-template-columns: minmax(0,2fr) minmax(260px,1fr); gap: 22px; align-items: start; }
.studio-head { display: flex; align-items: flex-start; gap: 18px; flex-wrap: wrap; }
.studio-head .studio-mark { width: 78px; height: 78px; border-radius: 14px; font-size: 25px; }
.crumb { margin-bottom: 14px; font-size: 12px; }
.crumb a { color: var(--secondary); text-decoration: none; }
.fact-list { padding: 5px 17px; background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); }
.fact-list div { display: grid; grid-template-columns: 42% 1fr; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.fact-list div:last-child { border-bottom: 0; }
.fact-list .key { color: var(--muted); }
.studio-game-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(210px,1fr)); gap: 14px; }
.studio-game { overflow: hidden; color: inherit; background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; }
.studio-game:hover { border-color: #66527c; }
.studio-game img { display: block; width: 100%; aspect-ratio: 16/9; object-fit: cover; }
.studio-game div { padding: 9px 11px; font-size: 12.5px; }
.source-list { padding-left: 18px; color: var(--muted); font-size: 12px; word-break: break-word; }
.source-list li { margin-bottom: 5px; }
.empty { display: grid; justify-items: center; padding: 62px 24px; border: 1px dashed var(--border); border-radius: var(--radius); text-align: center; background: rgba(18,16,24,.45); }
.empty h3 { margin: 15px 0 4px; font-size: 15px; }
.empty p { max-width: 52ch; margin: 0; color: var(--muted); font-size: 13px; }
.empty-orbit { width: 42px; height: 22px; border: 2px solid var(--luna); border-radius: 50%; transform: rotate(-18deg); box-shadow: 0 0 20px rgba(166,108,255,.22); }
.empty-orbit::after { content: ""; display: block; width: 7px; height: 7px; margin: -4px auto 0; border-radius: 50%; background: var(--luna-bright); box-shadow: 0 0 12px var(--luna); }
footer { padding: 20px 32px 40px; color: var(--muted); border-top: 1px solid var(--border); font-size: 12px; }
.footer-snapshot { margin-bottom: 5px; color: var(--secondary); }

@media (max-width: 900px) {
  .topnav { gap: 14px; padding: 0 18px; }
  .topnav nav { order: 3; }
  .homelink { margin-left: auto; }
  .pagehead, main { padding-left: 20px; padding-right: 20px; }
  .detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .topnav {
    height: auto; min-height: 88px; padding: 8px 14px 7px;
    display: grid; grid-template-columns: minmax(0, 1fr) auto;
    align-items: center; column-gap: 10px; row-gap: 5px;
  }
  .wordmark {
    min-width: 0; width: max-content; max-width: 100%;
    grid-column: 1; grid-row: 1;
    flex-direction: column; align-items: flex-start; gap: 1px;
  }
  .luna-logo { width: 78px; height: 23px; object-position: left center; }
  .research-label { display: block; font-size: 0; line-height: 1; }
  .research-label::after {
    content: "RESEARCH"; display: block;
    color: var(--muted); font-size: 9px; font-weight: 700;
    letter-spacing: .12em; line-height: 1.2; white-space: nowrap;
  }
  .topnav nav {
    grid-column: 1 / -1; grid-row: 2; order: initial; width: 100%; min-width: 0;
    justify-content: stretch;
  }
  .nav-tab { flex: 1 0 auto; padding: 6px 10px; text-align: center; font-size: 12px; }
  .homelink { grid-column: 2; grid-row: 1; margin-left: 0; max-width: 100%; font-size: 11px; padding: 7px 9px; }
  .ambient { top: 88px; }
  .toolbar { top: 88px; }
  input[type="search"] { width: 100%; min-width: 0; }
  input, select, button { max-width: 100%; }
  .pagehead { padding: 22px 16px 16px; }
  .pagehead h1 { font-size: 26px; }
  main { width: 100%; min-width: 0; padding: 18px 16px 52px; }
  main > *, .tab-panel, .section-block, .card, .map-card, .detail-grid, .fact-list { min-width: 0; max-width: 100%; }
  footer { padding: 18px 16px 32px; }
  .charts .card { flex-basis: min(82vw, 330px); }
  .map-viewport { height: 410px; }
  .map-pop { min-width: 0; width: min(280px, calc(100% - 20px)); }
  .directory-grid, .feature-grid, .game-grid, .studio-game-grid { grid-template-columns: minmax(0, 1fr); }
  .source-list { overflow-wrap: anywhere; }
}

@media (max-width: 360px) {
  .topnav { padding-left: 10px; padding-right: 10px; }
  .luna-logo { width: 72px; }
  .homelink { font-size: 10px; padding-left: 7px; padding-right: 7px; }
  .pagehead, main { padding-left: 12px; padding-right: 12px; }
  .fact-list div { grid-template-columns: minmax(0, 38%) minmax(0, 1fr); }
}
