:root {
  color-scheme: dark;
  --surface-0: #0b0b0b;
  --surface-1: #141414;
  --surface-2: #1f1f1f;
  --surface-3: #2a2a2a;
  --border: #333;
  --text-primary: #ffffff;
  --text-secondary: #b3b3b3;
  --text-muted: #7a7a7a;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --netflix: #e50914;
  --good: #0ca30c;
  --warning: #fab219;
  --critical: #d03b3b;
  --radius: 4px;
}
* { box-sizing: border-box; }
html { max-width: 100%; overflow-x: clip; }
body {
  margin: 0; background: var(--surface-0); color: var(--text-primary);
  font-family: "Netflix Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 15px; line-height: 1.5;
  position: relative; max-width: 100%; overflow-x: clip;
}
a { color: var(--series-1); }

/* ---------- ambient effects ---------- */
.side-rays {
  position: absolute;
  top: 56px; right: 0; left: 0;
  height: min(720px, 78vh);
  overflow: hidden;
  pointer-events: none;
  z-index: 4;
  opacity: .42;
  mix-blend-mode: screen;
  mask-image: linear-gradient(to bottom, #000 0%, #000 62%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, #000 62%, transparent 100%);
}
.side-rays canvas { display: block; width: 100%; height: 100%; }
@media (prefers-reduced-motion: reduce) { .side-rays { opacity: .28; } }

/* ---------- top nav ---------- */
.topnav {
  display: flex; align-items: center; gap: 26px;
  padding: 0 32px; height: 56px;
  background: var(--surface-0); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 60;
}
.topnav .wordmark { display: inline-flex; align-items: center; gap: 9px; color: var(--netflix); text-decoration: none; flex: none; }
.topnav .wordmark img { display: block; width: 86px; height: auto; }
.topnav .wordmark span { color: var(--text-muted); font-size: 11px; font-weight: 600; letter-spacing: .06em; white-space: nowrap; }
.topnav nav { display: flex; gap: 4px; margin-left: 8px; }
.topnav nav a {
  color: var(--text-secondary); text-decoration: none; font-size: 14px;
  padding: 7px 14px; border-radius: 20px; white-space: nowrap;
}
.topnav nav a:hover { color: #fff; background: var(--surface-2); }
.topnav nav a[aria-current="page"] { color: #fff; background: var(--surface-3); font-weight: 600; }

/* ---------- page chrome ---------- */
.pagehead { padding: 26px 32px 18px; border-bottom: 1px solid var(--border); background: linear-gradient(180deg, #1a0709 0%, var(--surface-0) 100%); }
.pagehead h1 { margin: 0 0 6px; font-size: 28px; letter-spacing: -.02em; }
.pagehead p { margin: 0; color: var(--text-secondary); font-size: 14px; max-width: 90ch; }
main { padding: 24px 32px 64px; max-width: 1600px; margin: 0 auto; }
section { margin-bottom: 34px; }
h2 { font-size: 17px; margin: 0 0 14px; font-weight: 600; }
footer { color: var(--text-muted); font-size: 12px; padding: 20px 32px 40px; border-top: 1px solid var(--border); }
.footer-snapshot { margin-bottom: 5px; color: var(--text-secondary); }
.hidden { display: none !important; }

/* ---------- stat tiles ---------- */
.tiles {
  display: flex; flex-wrap: nowrap; gap: 12px;
  overflow-x: auto; overflow-y: hidden;
  margin-bottom: 28px; padding-bottom: 10px;
  scroll-snap-type: x proximity;
  scrollbar-color: var(--surface-3) transparent;
  scrollbar-width: thin;
}
.tiles::-webkit-scrollbar { height: 8px; }
.tiles::-webkit-scrollbar-track { background: transparent; }
.tiles::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 999px; }
.tiles::-webkit-scrollbar-thumb:hover { background: #444; }
.tile { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.tiles .tile { flex: 0 0 clamp(168px, 17vw, 220px); scroll-snap-align: start; }
.tile .n { font-size: 30px; font-weight: 700; line-height: 1.1; letter-spacing: -.02em; }
.tile .l { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* ---------- cards & charts ---------- */
.charts {
  display: flex; flex-wrap: nowrap; gap: 16px;
  overflow-x: auto; overflow-y: hidden;
  padding-bottom: 12px;
  scroll-snap-type: x proximity;
  scrollbar-color: var(--surface-3) transparent;
  scrollbar-width: thin;
}
.charts::-webkit-scrollbar { height: 8px; }
.charts::-webkit-scrollbar-track { background: transparent; }
.charts::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 999px; }
.charts::-webkit-scrollbar-thumb:hover { background: #444; }
.charts .card { flex: 0 0 clamp(330px, 32vw, 440px); scroll-snap-align: start; }
.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; overflow: hidden; }
.card h3 { margin: 0 0 3px; font-size: 14px; font-weight: 600; }
.card .cap { margin: 0 0 14px; font-size: 12px; color: var(--text-muted); }

.bars { display: flex; flex-direction: column; gap: 7px; }
.bar-row { display: grid; grid-template-columns: minmax(84px, 34%) 1fr auto; align-items: center; gap: 10px; font-size: 12.5px; }
.bar-label { color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { display: block; background: var(--surface-3); border-radius: 3px; height: 12px; position: relative; overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 0 4px 4px 0; background: var(--series-1); min-width: 2px; transition: width .3s; }
.bar-val { color: var(--text-primary); font-variant-numeric: tabular-nums; font-size: 12px; min-width: 22px; text-align: right; }
.bar-row:hover .bar-label, .bar-row:hover .bar-val { color: #fff; }

.cols { display: flex; align-items: flex-end; gap: 3px; height: 130px; margin-bottom: 6px; }
.col-wrap { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; position: relative; }
.col { background: var(--series-1); border-radius: 4px 4px 0 0; min-height: 2px; }
.col-wrap:hover .col { background: #6da7ec; }
.col-axis { display: flex; gap: 3px; font-size: 10px; color: var(--text-muted); }
.col-axis span { flex: 1; text-align: center; }
.col-wrap .cval { position: absolute; top: -15px; width: 100%; text-align: center; font-size: 10px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }

/* ---------- toolbar ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; padding: 14px 16px; background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); position: sticky; top: 56px; z-index: 20; }
select, input[type=search] { background: var(--surface-2); color: var(--text-primary); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 10px; font-size: 13px; font-family: inherit; min-width: 150px; }
input[type=search] { min-width: 230px; }
select:focus, input:focus { outline: 2px solid var(--series-1); outline-offset: 1px; }
.sortlab { display: inline-flex; align-items: center; gap: 7px; color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.count { margin-left: auto; color: var(--text-secondary); font-size: 13px; }
button.reset { background: var(--surface-3); color: var(--text-primary); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 12px; font-size: 13px; cursor: pointer; font-family: inherit; }
button.reset:hover { background: #3a3a3a; }
.viewtoggle { display: flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.viewtoggle button { background: var(--surface-2); color: var(--text-secondary); border: 0; padding: 8px 13px; font-size: 13px; cursor: pointer; font-family: inherit; }
.viewtoggle button[aria-pressed=true] { background: var(--series-1); color: #fff; }

/* ---------- tables ---------- */
.tablewrap { overflow: auto; max-height: calc(100vh - var(--toolbar-h, 74px) - 108px); border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--text-secondary); font-weight: 600; font-size: 12px; position: sticky; top: 0; background: var(--surface-2); cursor: pointer; user-select: none; z-index: 10; white-space: nowrap; }
th:hover { color: #fff; }
th[data-sort].sorted { color: #fff; }
th[data-sort].sorted::after { content: " \25B2"; color: var(--series-1); }
th[data-sort].sorted.desc::after { content: " \25BC"; }
tbody tr:hover { background: var(--surface-1); }
td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- chips & logos ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { font-size: 10.5px; background: var(--surface-3); color: var(--text-secondary); padding: 2px 7px; border-radius: 20px; white-space: nowrap; }
.chip.plat { background: #1d3350; color: #9dc3f2; }
.chip.nflx { background: #3a1013; color: #f0a0a5; }
.chip.acq { background: #14322a; color: #7fd8b6; }
.chip.closed { background: #3a2412; color: #e8b088; }

.logo-badge {
  width: 34px; height: 34px; border-radius: 7px; flex: none;
  background: var(--surface-3); display: grid; place-items: center; overflow: hidden;
}
.logo-badge img { max-width: 86%; max-height: 76%; object-fit: contain; display: block; }
.logo-badge .mono { font-size: 13px; font-weight: 700; color: var(--text-secondary); letter-spacing: -.02em; }

/* ---------- studio map ---------- */
.mapcard { padding: 0; position: relative; }
.mapbar { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.mapbar h3 { margin: 0; font-size: 14px; }
.mapbar .cap { margin: 0; }
.mapzoom { margin-left: auto; display: flex; gap: 6px; }
.mapzoom button { width: 30px; height: 30px; background: var(--surface-2); color: var(--text-primary); border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; font-size: 15px; line-height: 1; font-family: inherit; }
.mapzoom button:hover { background: var(--surface-3); }
.mapzoom button.wide { width: auto; padding: 0 11px; font-size: 12px; }
.mapviewport { position: relative; height: 560px; overflow: hidden; background: #0e1621; cursor: grab; }
.mapviewport.dragging { cursor: grabbing; }
.mapviewport svg { width: 100%; height: 100%; display: block; touch-action: none; }
.country { fill: #1d2836; stroke: #2b3a4d; stroke-width: .4; vector-effect: non-scaling-stroke; }
.country.has-studios { fill: #26384f; }
.pin { cursor: pointer; }
.pin .halo { fill: rgba(0,0,0,.55); stroke: var(--series-1); stroke-width: 1.6; vector-effect: non-scaling-stroke; }
.pin:hover .halo, .pin.active .halo { stroke: #fff; stroke-width: 2.4; }
.pin .badge-bg { fill: var(--netflix); }
.pin .badge-tx { fill: #fff; font-size: 9px; font-weight: 700; text-anchor: middle; font-family: inherit; }
.maptip {
  position: absolute; pointer-events: none; z-index: 5;
  background: rgba(10,10,10,.96); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 7px 10px; font-size: 12px; max-width: 260px; box-shadow: 0 6px 20px rgba(0,0,0,.6);
}
.maptip .t { font-weight: 600; }
.maptip .s { color: var(--text-muted); font-size: 11px; }
.mappop {
  position: absolute; z-index: 6; background: var(--surface-1); border: 1px solid #555;
  border-radius: var(--radius); padding: 10px 12px; min-width: 220px; max-width: 300px;
  box-shadow: 0 10px 30px rgba(0,0,0,.7); max-height: 320px; overflow: auto;
}
.mappop h4 { margin: 0 0 8px; font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }
.mappop a { display: flex; align-items: center; gap: 8px; padding: 5px 0; text-decoration: none; color: var(--text-primary); font-size: 13px; }
.mappop a:hover { color: var(--series-1); }
.mappop .logo-badge { width: 26px; height: 26px; border-radius: 5px; }
.maplegend { display: flex; gap: 14px; padding: 10px 16px; border-top: 1px solid var(--border); font-size: 11.5px; color: var(--text-muted); flex-wrap: wrap; }

/* ---------- studio detail ---------- */
.studiohead { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 8px; }
.studiohead .logo-badge { width: 84px; height: 84px; border-radius: 14px; }
.studiohead .logo-badge .mono { font-size: 30px; }
.studiohead h1 { margin: 0 0 4px; }
.crumb { font-size: 12.5px; color: var(--text-muted); margin-bottom: 14px; }
.crumb a { color: var(--text-secondary); text-decoration: none; }
.crumb a:hover { color: #fff; text-decoration: underline; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: 22px; align-items: start; }
@media (max-width: 900px) { .detail-grid { grid-template-columns: 1fr; } }
.factlist { display: flex; flex-direction: column; gap: 0; }
.factlist div { display: grid; grid-template-columns: 42% 1fr; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.factlist div:last-child { border-bottom: 0; }
.factlist dt, .factlist .k { color: var(--text-muted); }
.factlist .v { color: var(--text-primary); }
.factlist .v.none { color: var(--text-muted); font-style: italic; }
.sociallinks { display: flex; flex-wrap: wrap; gap: 7px; }
.sociallinks a { font-size: 12px; padding: 5px 11px; background: var(--surface-3); border-radius: 20px; text-decoration: none; color: var(--text-secondary); }
.sociallinks a:hover { background: #3a3a3a; color: #fff; }
.gamegrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.gamecard { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; text-decoration: none; color: inherit; display: block; }
.gamecard:hover { border-color: #555; }
.gamecard .art { position: relative; aspect-ratio: 16/9; background: var(--surface-2); }
.gamecard .art img.bg { width: 100%; height: 100%; object-fit: cover; display: block; }
.gamecard .art::after { content: ""; position: absolute; inset: 40% 0 0; background: linear-gradient(180deg, transparent, rgba(0,0,0,.75)); }
.gamecard .art img.lg { position: absolute; left: 9px; bottom: 8px; z-index: 1; width: 62%; max-height: 44%; object-fit: contain; object-position: left bottom; filter: drop-shadow(0 2px 6px rgba(0,0,0,.9)); }
.gamecard .cap2 { padding: 9px 11px; font-size: 12.5px; }
.gamecard .cap2 .yr { color: var(--text-muted); font-size: 11.5px; }
.sourcelist { font-size: 12px; color: var(--text-muted); word-break: break-all; }
.sourcelist li { margin-bottom: 4px; }
.conf { font-size: 11px; padding: 2px 8px; border-radius: 20px; }
.conf.high { background: #14322a; color: #7fd8b6; }
.conf.medium { background: #3a2f12; color: #e0c579; }
.conf.low { background: #3a1013; color: #f0a0a5; }
.studio-name-cell { display: flex; align-items: center; gap: 9px; }
.studio-name-cell a { text-decoration: none; color: var(--text-primary); font-weight: 600; }
.studio-name-cell a:hover { color: var(--series-1); }
.topnav .homelink {
  color: var(--text-primary); font-size: 12px; line-height: 1;
  text-decoration: none; margin-left: auto; white-space: nowrap;
  padding: 7px 11px; border: 1px solid rgba(255,255,255,.7); border-radius: 999px;
  transition: background-color .15s, border-color .15s;
}
.topnav .homelink:hover { color: #fff; background: rgba(255,255,255,.1); border-color: #fff; }
@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;
  }
  .topnav .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;
  }
  .topnav .wordmark img { width: 78px; }
  .topnav .wordmark span { font-size: 0; line-height: 1; }
  .topnav .wordmark span::after {
    content: "RESEARCH"; display: block;
    color: var(--text-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; width: 100%; min-width: 0; margin-left: 0;
    overflow-x: auto; overflow-y: hidden; scrollbar-width: none;
  }
  .topnav nav::-webkit-scrollbar { display: none; }
  .topnav nav a { flex: 1 0 auto; padding: 6px 10px; text-align: center; font-size: 12px; }
  .topnav .homelink { grid-column: 2; grid-row: 1; margin-left: 0; max-width: 100%; font-size: 11px; padding: 7px 9px; }
  .side-rays { top: 88px; }
  .toolbar { top: 88px; }
  .pagehead { padding: 22px 16px 16px; }
  .pagehead h1 { font-size: 25px; line-height: 1.15; }
  main { width: 100%; min-width: 0; padding: 18px 16px 52px; }
  main > *, section, .card, .mapcard, .detail-grid, .factlist { min-width: 0; max-width: 100%; }
  footer { padding: 18px 16px 32px; }
  .charts .card { flex-basis: min(82vw, 330px); }
  .mapviewport { height: 410px; }
  .mappop { min-width: 0; width: min(280px, calc(100% - 20px)); }
  select, input[type=search] { max-width: 100%; }
  input[type=search] { width: 100%; min-width: 0; }
}

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