:root {
  color-scheme: dark;
  scrollbar-gutter: stable;
  font-family: system-ui, sans-serif;
  color: #eef1f5;
  background: #101319;
  --muted: #a4afbd;
  --line: #2c3541;
  --accent: #8db9ff;
  --surface: #181e27;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
main { width: min(74rem, 100% - 2rem); margin-inline: auto; padding: 2rem 0 3rem; }
h1, h2, p { margin: 0; }
h2 { font-size: 1.125rem; font-weight: 680; }

.masthead {
  position: relative;
  max-width: 42rem;
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .4rem;
  margin-bottom: 1.75rem;
}
#help-open {
  display: grid; place-items: center; width: 2.75rem; height: 2.75rem; padding: 0;
  border: 0; border-radius: 50%; color: inherit; background: transparent;
}
#help-open { position: absolute; right: 0; top: 0; }
#help-open span {
  display: grid; place-items: center; width: 1.5rem; height: 1.5rem; border: 2px solid currentColor;
  border-radius: 50%; font: 700 1rem/1 system-ui, sans-serif;
}
#help-open:hover { background: #2a323e; }
h1 { font-size: clamp(2rem, 5vw, 2.75rem); font-weight: 750; letter-spacing: -.055em; line-height: 1; }
time { color: var(--muted); font-size: .875rem; white-space: nowrap; }
.reset-countdown { color: var(--muted); font-size: .75rem; font-variant-numeric: tabular-nums; }
.game-modes { display: flex; justify-content: center; gap: 1.25rem; margin: -.5rem auto 1.25rem; }
.game-modes a { padding: .35rem .15rem; color: var(--muted); text-decoration: none; }
.game-modes a[aria-current] { color: inherit; border-bottom: 2px solid var(--accent); font-weight: 650; }
.next-round { display: block; margin: .5rem auto; padding: .55rem 1rem; border: 1px solid var(--line); border-radius: .35rem; color: var(--accent); background: var(--surface); }

button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

form { position: relative; max-width: 35rem; margin-inline: auto; }
label { display: block; margin-bottom: .375rem; font-size: .875rem; font-weight: 650; }
.controls { display: flex; gap: .5rem; }
input {
  flex: 1;
  min-width: 0;
  padding: .65rem .8rem;
  color: inherit;
  background: var(--surface);
  border: 1px solid #475468;
  border-radius: .35rem;
}
input::placeholder { color: var(--muted); }
#submit { padding: .65rem 1rem; background: var(--accent); color: #111a28; border: 0; border-radius: .35rem; font-weight: 650; }
#submit:enabled:hover { background: #a9caff; }
#submit:disabled { opacity: .5; }
#options {
  position: absolute;
  z-index: 2;
  inset: 100% 0 auto;
  margin: .25rem 0 0;
  padding: .25rem;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: .35rem;
  max-height: 16rem;
  overflow-y: auto;
}
.masthead time:empty, .reset-countdown:empty { display: none; }
.game { width: min(58rem, 100%); margin-inline: auto; }
.game-info { display: flex; align-items: baseline; justify-content: space-between; gap: .7rem; margin-bottom: .65rem; }
#used, .graph-footer, .hint { color: var(--muted); font-size: .875rem; }
#used { font-variant-numeric: tabular-nums; white-space: nowrap; }

#tree-view {
  --row-height: 2.15rem;
  --layers: 0;
  height: max(0px, calc(var(--layers) * (var(--row-height) + 1px) - 1px));
  overflow: hidden;
  touch-action: none;
  user-select: none;
  overflow-anchor: none;
}
#tree {
  position: relative;
  --bar-height: calc(var(--row-height) * var(--row-scale, 1));
  height: max(0px, calc(var(--layers) * (var(--bar-height) + 1px) - 1px));
}
.bar {
  position: absolute;
  top: calc(var(--depth) * (var(--bar-height) + 1px));
  height: var(--bar-height);
  container-type: inline-size;
  display: flex;
  align-items: center;
  min-width: 0;
  padding: 0;
  overflow: clip;
  border: 0;
  border-radius: 0;
  background: var(--fill);
  color: #17191e;
  text-align: left;
  font: 560 .84rem/1.15 ui-monospace, monospace;
}
/* Keep exiting bars in place until their width and opacity reach zero. */
.bar[inert] { opacity: 0; visibility: hidden; pointer-events: none; }
@media (prefers-reduced-motion: no-preference) {
  #tree-view.reflowing, .reflowing #tree { transition: height 360ms ease-in-out; }
  .reflowing .bar {
    transition: left 360ms ease-in-out, width 360ms ease-in-out, opacity 240ms ease,
      background-color 200ms ease, visibility 0s;
  }
  .reflowing .bar[inert] { transition-delay: 0s, 0s, 0s, 0s, 360ms; }
}
.tree-filter { display: inline-flex; align-items: center; gap: .35rem; margin: 0 .55rem 0 0; font-size: inherit; font-weight: 400; cursor: pointer; }
.tree-filter input { flex: none; margin: 0; padding: 0; accent-color: var(--accent); }
.bar-label {
  display: block;
  position: sticky;
  left: 0;
  width: min(100%, var(--view-width, 100vw));
  padding-inline: .45rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@container (max-width: 4.5rem) { .bar-label { padding-inline: .2rem; } }
/* Anchor the crop to the visible label when a zoomed bar is wider than the viewport. */
.bar:not([data-id="politics"]) {
  --surface-tint: color-mix(in srgb, var(--fill) 31%, #101823);
  background-color: var(--surface-tint);
  color: white;
}
.bar:not([data-id="politics"]) .bar-label {
  isolation: isolate;
  height: 100%;
  line-height: var(--bar-height);
  text-shadow: 0 1px 3px #080b10;
}
.bar:not([data-id="politics"]) .bar-label::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0 0 0 auto;
  width: min(100%, calc(var(--bar-height) * 6));
  background: linear-gradient(90deg, var(--surface-tint), transparent 65%),
    linear-gradient(#10151c52, #10151c52), var(--photo) center var(--focus-y, 28%) / cover no-repeat;
}
.bar:is([data-id="nationalism"], [data-id="green-politics"], [data-id="socialism"],
  [data-id="anarcho-syndicalism"], [data-id="direct-democracy"], [data-id="ecomodernism"],
  [data-id="democracy"], [data-id="liberalism"], [data-id="accelerationism"],
  [data-id="effective-accelerationism"], [data-id="nazism"], [data-id="owenism"],
  [data-id="brazilian-republicanism"], [data-id="stalinism"], [data-id="utopian-socialism"]) { --focus-y: 52%; }
.bar[data-id="politics"] { background: #465362; color: #fff; }
.bar.shared { --surface-tint: #24543d; background: #367253; color: #fff; }
.bar.excluded { --surface-tint: #303843; background: #303843; color: #abb5c1; }
.bar.shared .bar-label::before { opacity: .45; }
.bar.excluded .bar-label::before { opacity: .16; filter: grayscale(1); }
.bar[aria-pressed="true"] { box-shadow: inset 0 0 0 2px white; }
.bar:hover, .bar:focus-visible { filter: brightness(1.15); outline: 2px solid #f6f8fa; outline-offset: -2px; }
.graph-footer { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: .5rem; min-height: 1.65rem; margin-top: .55rem; }
#tree-note { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-tools { display: flex; flex: none; align-items: baseline; gap: .35rem; }
.tree-tools output { min-width: 4ch; text-align: center; font-variant-numeric: tabular-nums; }
.tree-tools button { border: 0; background: transparent; color: var(--accent); padding: .15rem .4rem; min-height: 1.75rem; }
.tree-tools button:disabled { color: var(--muted); opacity: .55; }
#tree-view.dragging, #tree-view.dragging .bar { cursor: grabbing; }
#tree-reset { flex: none; padding: 0; border: 0; background: none; color: var(--accent); font-size: inherit; text-decoration: underline; text-underline-offset: .15em; }
#guess-form { margin-top: 1.35rem; }
#options li { padding: .5rem; color: inherit; cursor: pointer; }
#options li[aria-selected="true"], #options li:hover { background: #252e3b; }
#options small { color: var(--muted); margin-left: .6rem; }
.hint { margin: .55rem auto; text-align: center; }
.hint:empty { display: none; }
.history-scroll { max-width: 100%; }
.history { width: min(100%, 44rem); margin: 1.5rem auto 0; border-spacing: .22rem; table-layout: fixed; text-align: center; }
.history caption { color: var(--muted); font-size: .8rem; padding-bottom: .4rem; }
.history thead th { color: var(--muted); font-size: clamp(.64rem, 2.5vw, .8rem); padding: .3rem 0; }
.history thead th:first-child { width: 20%; }
.history tbody td, .history tbody th { padding: 0; border-radius: .15rem; background: #2a323e; }
.history tbody .match { background: #235842; }
.history tbody .direction { background: #604621; }
.history .unused td { background: transparent; border: 1px solid #343d49; color: var(--muted); font: .75rem ui-monospace, monospace; }
.history .tile-face, .history .history-entry {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .2rem;
  width: 100%; min-height: 0; border: 0; padding: .15rem; background: transparent; color: inherit;
  text-align: center; overflow-wrap: anywhere; font: 650 clamp(.65rem, 2.4vw, .8rem)/1.1 ui-monospace, monospace;
}
.history tbody th { position: relative; }
.history .history-entry { position: absolute; inset: 0; height: 100%; overflow: hidden; }
.history .tile-face { aspect-ratio: 1; overflow: hidden; cursor: help; font-family: system-ui, sans-serif; }
.tile-face span { max-width: 100%; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.history .unused td:nth-child(2)::before { content: ""; display: block; aspect-ratio: 1; }
.tile-face svg { width: 1.4rem; height: 1.4rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#tile-tip { position: fixed; z-index: 5; pointer-events: none; max-width: min(22rem, calc(100vw - 12px)); padding: .45rem .7rem; border-radius: .3rem; background: #f1f4fa; color: #182333; font-size: .875rem; }
#reveal { width: min(35rem, calc(100vw - 2rem)); }
.result-photo { margin: .75rem 0; }
.result-photo img { display: block; width: 100%; height: clamp(8rem, 24dvh, 15rem); object-fit: contain; background: #0b0e13; }
.result-photo figcaption { margin-top: .25rem; }
#reveal .next-round, #share-text { width: 100%; }
#copy-status { text-align: center; font-size: .85rem; }
#copy-status:empty { display: none; }
#reveal h2 { font-size: 1.55rem; }
#reveal p { margin-block: .45rem; }
#reveal a { color: var(--accent); }
.result-title { font-weight: 650; }
.facts { color: var(--muted); font-size: .9rem; }
dialog { color: inherit; background: #15191f; border: 1px solid var(--line); border-radius: .5rem; width: min(30rem,calc(100vw - 2rem)); max-height: 85dvh; padding: 1.5rem; }
dialog::backdrop { background: rgb(5 8 12 / 82%); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; }
.dialog-head h2 { font: 700 2rem/1.1 Georgia,serif; }
.dialog-head form { margin: 0; }
.close { font-size: 1.65rem; background: none; color: inherit; border: 0; }
dialog p { margin: .6rem 0; line-height: 1.45; }
dialog h3 { font-size: 1.04rem; margin: 1.2rem 0 .4rem; }
.help-foot { color: var(--muted); font-size: .875rem; border-top: 1px solid var(--line); padding-top: 1rem; }
@media (max-width: 36rem) {
  main { width: calc(100% - 1.25rem); padding-top: 1.4rem; }
  #tree-view { --row-height: 2.5rem; }
  .graph-footer { grid-template-columns: 1fr; gap: 0; }
  .tree-tools { grid-row: 1; justify-self: end; }
}

#workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 0rem;
  align-items: start;
  overflow-x: clip;
}
#workspace.show-reference { grid-template-columns: minmax(0, 1fr) min(32vw, 23rem); }
#reference { min-width: 0; height: 0; overflow: clip; visibility: hidden; }
.show-reference #reference { height: auto; visibility: visible; }
.reference-body {
  width: min(32vw, 23rem);
  padding-left: clamp(1rem, 2.5vw, 2.25rem);
  opacity: 0;
  transform: translateX(1.5rem);
}
.show-reference .reference-body { opacity: 1; transform: none; }
#reference-close, .history-entry {
  border: 0; padding: 0; background: none; color: var(--accent); text-align: left;
}
#reference-close { min-height: 2rem; margin-bottom: .65rem; font-size: .875rem; }
#reference-close:hover, .history-entry:hover { text-decoration: underline; }
.history-entry { font-weight: 650; }
figcaption { color: var(--muted); font-size: .8rem; line-height: 1.45; }
#reference-title { margin: .25rem 0 .9rem; font-size: clamp(1.55rem, 3vw, 2rem); line-height: 1.12; letter-spacing: -.035em; }
#reference figure { margin: 0 0 .85rem; }
#reference-image { display: block; width: 100%; height: 13rem; object-fit: contain; background: #0b0e13; }
#reference figcaption { margin-top: .45rem; }
.image-credit summary { cursor: pointer; width: fit-content; }
#reference-summary { line-height: 1.5; }
#reference a { color: var(--accent); text-underline-offset: .15em; }
#reference-source { display: inline-block; margin-top: .75rem; font-size: .875rem; }
@media (prefers-reduced-motion: no-preference) {
  #workspace { transition: grid-template-columns 300ms ease; }
  .reference-body { transition: opacity 220ms ease, transform 300ms ease; }
}
@media (max-width: 52rem) {
  #workspace, #workspace.show-reference { grid-template-columns: minmax(0, 1fr); }
  .game { display: contents; }
  .page-heading { grid-area: 1 / 1; }
  .board, #reference { grid-area: 2 / 1; }
  .round { grid-area: 3 / 1; }
  .show-reference .board { visibility: hidden; contain: size; overflow: clip; transform: translateX(-100%); }
  .reference-body { width: 100%; padding: 0; transform: translateX(100%); }
  #reference figure { float: right; width: 41%; margin: 0 0 .75rem 1rem; }
  #reference-image { height: clamp(7rem, 25vw, 12rem); }
  #reference-close { margin-bottom: .3rem; }
  @media (prefers-reduced-motion: no-preference) {
    .board { transition: transform 300ms ease, visibility 0s; }
    .show-reference .board { transition-delay: 0s, 300ms; }
  }
}

.timeline { margin-top: 1rem; }
.time-heading, #time-axis { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.time-heading h3 { margin: 0; font-size: .88rem; }
#time-detail, #time-axis { color: var(--muted); font: .74rem/1.4 ui-monospace, monospace; }
.time-track { position: relative; }
.time-track { display: grid; align-items: center; height: 1.75rem; }
#time-band { position: relative; height: .5rem; overflow: hidden; background: #848c98; }
#time-band.scored { background: #b66164; }
#time-window { display: none; position: absolute; inset-block: 0; min-width: 1px; background: #86dba7; }
.scored #time-window { display: block; }
#time-band.inspecting::after { content: ""; position: absolute; inset-block: 0; left: var(--cursor); width: 2px; background: white; box-shadow: 0 0 0 1px #15191f; }
#time-cursor { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; margin: 0; padding: 0; cursor: crosshair; }
.time-track:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
#time-axis { position: relative; height: 1.2rem; }
#time-axis span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
#time-axis span:first-child { transform: none; }
#time-axis span:last-child { transform: translateX(-100%); }

.history thead button {
  width: 100%; min-height: 2rem; padding: 0; border: 0; background: transparent;
  font: inherit; color: inherit; text-decoration: underline dotted; text-underline-offset: .25em;
}
.history thead button:hover { color: var(--accent); }
#guide-values ul { columns: 2 10rem; padding: 0; margin: .75rem 0 0; list-style: none; }
#guide-values li { break-inside: avoid; padding-block: .2rem; }

.compact-heading { display: none; }
@media (max-width: 34rem) {
  .round { min-width: 0; }
  .history, .history caption, .history thead, .history tbody { display: block; }
  .history tr { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
  .history thead th:first-child { display: none; }
  .history .full-heading { display: none; }
  .history .compact-heading { display: inline; }
  .history tbody tr { margin-bottom: .4rem; }
  .history tbody th {
    grid-column: 1 / -1; background: transparent; border: 0; text-align: left;
  }
  .history .history-entry { position: static; width: auto; padding: .2rem 0; display: block; text-align: left; font-size: .8rem; }
  .history th.match .history-entry { color: #86dba7; }
  .history .unused td:first-child { display: grid; place-items: center; aspect-ratio: 1; }
  .history .unused td:nth-child(2) { display: none; }
  .history .tile-face span { display: none; }
  .history .tile-face svg { width: 50%; height: 50%; }
  .history thead button { min-height: 2.25rem; }
}
