*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background-color: #1a202c;
  color: #e2e8f0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  display: block;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 0;
}

p {
  margin: 0;
}

/* Nav bar */
.nav-bar {
  display: flex;
  align-items: center;
  padding-left: 24px;
  background-color: #171923;
  user-select: none;
}

.nav-inner {
  display: flex;
  align-items: center;
  width: 100%;
}

.nav-logo {
  margin-right: 24px;
}

.nav-links {
  display: flex;
  align-items: center;
}

.menu-link {
  display: flex;
  align-items: center;
  padding: 16px 24px;
  text-transform: uppercase;
  font-weight: bold;
  font-size: 12px;
  cursor: pointer;
}

.menu-link:focus {
  outline: none;
}

.menu-link.active {
  background-color: #1a365d;
}

.nav-end {
  margin-left: auto;
}

/* Layout */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 16px;
}

.vstack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.hstack {
  display: flex;
  align-items: center;
}

.hstack-6 {
  gap: 24px;
}

/* Section */
.section {
  background-color: #2d3748;
  border: 2px solid #3182ce;
  border-radius: 8px;
  overflow: hidden;
  width: 100%;
}

/* Table */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

table.fixed {
  table-layout: fixed;
}

th {
  text-align: left;
  padding: 8px 16px;
  font-size: 11px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #a0aec0;
  border-bottom: 2px solid #4a5568;
}

td {
  padding: 8px 16px;
  border-top: 1px solid #4a5568;
}

td.text-right {
  text-align: right;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  padding: 0 12px;
  font-size: 14px;
  font-weight: 500;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  background-color: #90cdf4;
  color: #1a202c;
  line-height: 1;
  white-space: nowrap;
}

.btn:hover {
  background-color: #3182ce;
}

.btn:active {
  background-color: #2b6cb0;
  text-decoration: underline;
}

.btn:focus {
  outline: none;
}

.btn-outline {
  background-color: transparent;
  border: 1px solid #90cdf4;
  color: #f7fafc;
}

.btn-outline:hover {
  background-color: #1a202c;
}

.btn-in-game {
  border: 2px solid #e0bf4f;
  background-color: #6a1411;
  color: #e0bf4f;
  border-radius: 0;
  text-transform: uppercase;
  text-shadow: 1px 1px 1px #000;
  font-family: "Cinzel", serif;
}

.btn-in-game:hover {
  background-color: #571411;
}

.btn-in-game:focus {
  outline: none;
}

/* Button group */
.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-group-right {
  justify-content: flex-end;
  width: 100%;
}

/* Kbd */
kbd {
  display: inline-block;
  padding: 2px 6px;
  font-size: 11px;
  font-family: monospace;
  border: 1px solid #718096;
  border-radius: 4px;
  background-color: #2d3748;
  color: #e2e8f0;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
}

/* Skeleton */
.skeleton {
  background: linear-gradient(90deg, #1a202c 0%, #2d3748 50%, #1a202c 100%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite linear;
  border-radius: 4px;
}

@keyframes skeleton-shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Heading utility */
.heading-md {
  font-size: 18px;
  font-weight: 600;
}

/* Matchup bar */
.matchup-bar {
  position: absolute;
  top: 52px;
  left: 0;
  right: 0;
  background: linear-gradient(to bottom, rgba(10, 12, 20, 0.92), rgba(10, 12, 20, 0.72));
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(74, 85, 104, 0.4);
  z-index: 10;
  padding: 5px 16px 7px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.matchup-tiles-col {
  flex: 1;
  min-width: 0;
}

.view-toggle {
  flex-shrink: 0;
  display: flex;
  gap: 4px;
  margin-right: 8px;
}

.generation-tiles {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  margin-bottom: 2px;
}

.generation-tiles::-webkit-scrollbar {
  display: none;
}

.generation-tiles--secondary {
  margin-top: 6px;
  margin-bottom: 8px;
  padding-left: 6px;
  border-left: 2px solid rgba(74, 85, 104, 0.35);
}

.gen-tile {
  position: relative;
  flex-shrink: 0;
  width: 58px;
  height: 58px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: rgba(45, 55, 72, 0.55);
  border: 1px solid rgba(74, 85, 104, 0.5);
  border-radius: 8px;
  cursor: grab;
  transition: border-color 0.15s, background 0.15s;
  padding: 6px;
  user-select: none;
}

.gen-tile:active {
  cursor: grabbing;
}

.gen-tile:hover {
  background: rgba(74, 85, 104, 0.6);
  border-color: rgba(160, 174, 192, 0.8);
}

.gen-tile--expanded {
  border-color: rgba(160, 174, 192, 0.7);
  background: rgba(74, 85, 104, 0.5);
}

.gen-tile--slotted-home {
  border: 3px solid #4299e1;
  box-shadow: 0 0 0 1px rgba(66, 153, 225, 0.3);
}

.gen-tile--slotted-away {
  border: 3px solid #fc8181;
  box-shadow: 0 0 0 1px rgba(252, 129, 129, 0.3);
}

.gen-tile--slotted-both {
  border: 3px solid;
  border-top-color: #fc8181;
  border-right-color: #fc8181;
  border-bottom-color: #4299e1;
  border-left-color: #4299e1;
  box-shadow: 0 0 0 1px rgba(66, 153, 225, 0.3);
}

.gen-tile--small {
  width: 46px;
  height: 46px;
}

.gen-tile__gen {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #a0aec0;
  font-weight: 600;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gen-tile--small .gen-tile__gen {
  font-size: 9px;
}

.gen-tile__elo {
  font-size: 18px;
  font-weight: bold;
  color: #e2e8f0;
  line-height: 1;
}

.gen-tile--small .gen-tile__elo {
  font-size: 14px;
}

.gen-tile__borrowed-icon {
  position: absolute;
  top: -6px;
  right: -6px;
  font-size: 11px;
  line-height: 1;
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(45, 55, 72, 0.9);
  border: 1px solid rgba(160, 174, 192, 0.6);
}

.matchup-slots {
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 24px;
}

.speed-controls {
  position: absolute;
  top: 14px;
  right: 16px;
  z-index: 20;
  display: flex;
  gap: 4px;
}

.speed-btn {
  background: rgba(45, 55, 72, 0.55);
  border: 1px solid rgba(74, 85, 104, 0.5);
  border-radius: 6px;
  color: #a0aec0;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 10px;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.speed-btn:hover {
  color: #e2e8f0;
  border-color: rgba(160, 174, 192, 0.6);
}

.speed-btn--active {
  color: #e0bf4f;
  border-color: #e0bf4f;
  background: rgba(224, 191, 79, 0.1);
}

.count-control {
  display: flex;
  align-items: center;
  gap: 4px;
  color: #a0aec0;
  font-size: 12px;
  font-weight: 600;
  margin-left: 16px;
}

.speed-controls .speed-btn--standalone {
  margin-left: 16px;
}

.bb-menu {
  position: relative;
}

.bb-menu__dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 30;
  max-height: 60vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  background: rgba(26, 32, 44, 0.95);
  border: 1px solid rgba(74, 85, 104, 0.6);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.bb-menu__item {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  color: #cbd5e0;
  font-size: 12px;
  font-weight: 500;
  padding: 2px 4px;
  cursor: pointer;
}

.bb-menu__item:hover {
  color: #e2e8f0;
}

.bb-menu__item input {
  cursor: pointer;
}

.count-control input {
  width: 52px;
  background: rgba(45, 55, 72, 0.55);
  border: 1px solid rgba(74, 85, 104, 0.5);
  border-radius: 6px;
  color: #e2e8f0;
  font-size: 12px;
  padding: 4px 6px;
}

.drop-slot {
  position: relative;
  width: 320px;
  height: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 2px dashed rgba(74, 85, 104, 0.5);
  border-radius: 8px;
  padding: 4px 114px 4px 12px;
  transition: border-color 0.15s, background 0.15s;
}

.drop-slot--over {
  border-color: #e0bf4f;
  background: rgba(224, 191, 79, 0.08);
}

.drop-slot--filled.drop-slot--home {
  border-style: solid;
  border-color: #4299e1;
  box-shadow: 0 0 0 1px rgba(66, 153, 225, 0.2);
}

.drop-slot--filled.drop-slot--away {
  border-style: solid;
  border-color: #fc8181;
  box-shadow: 0 0 0 1px rgba(252, 129, 129, 0.2);
}

.drop-slot__name {
  font-size: 14px;
  font-weight: 600;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  align-self: flex-start;
  width: 100%;
  text-align: left;
}

.drop-slot__empty {
  font-size: 12px;
  color: rgba(160, 174, 192, 0.3);
  font-style: italic;
}

.drop-slot__clear {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  right: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  background: #0d1117;
  border: none;
  border-radius: 4px;
  color: #e2e8f0;
  font-size: 13px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.drop-slot__clear:hover {
  color: #a0aec0;
}

.drop-slot__revert {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  right: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  background: #0d1117;
  border: none;
  border-radius: 4px;
  color: #e2e8f0;
  font-size: 16px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.drop-slot__revert:hover {
  color: #a0aec0;
}

.drop-slot__inspect {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  right: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  background: #0d1117;
  border: none;
  border-radius: 4px;
  color: #e2e8f0;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.drop-slot__inspect:hover {
  color: #a0aec0;
}

.drop-slot__dice {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  right: 86px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  background: #0d1117;
  border: none;
  border-radius: 4px;
  color: #e2e8f0;
  font-size: 16px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.drop-slot__dice:hover {
  color: #a0aec0;
}

.tree-modal__backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  /* Anchor to the top so the modal stays put as its content grows/shrinks
     rather than re-centering vertically. */
  align-items: flex-start;
  justify-content: center;
  padding: 40px 20px;
  background: rgba(0, 0, 0, 0.6);
}

/* Wraps the modal and its optional candidates panel. Sized to the modal alone
   (the panel is absolutely positioned) so the modal stays centred and fixed in
   place whether or not the panel is open. */
.tree-modal__layout {
  position: relative;
}

.tree-modal {
  display: flex;
  flex-direction: column;
  width: min(720px, 90vw);
  max-height: calc(100vh - 80px);
  background: #1a202c;
  border: 1px solid rgba(74, 85, 104, 0.6);
  border-radius: 10px;
  overflow: hidden;
}

.mutation-panel,
.mutation-log {
  /* Float alongside the modal without affecting its position. */
  position: absolute;
  top: 0;
  display: flex;
  flex-direction: column;
  width: 300px;
  max-height: calc(100vh - 80px);
  background: #1a202c;
  border: 1px solid rgba(74, 85, 104, 0.6);
  border-radius: 10px;
  overflow: hidden;
}

/* Candidates panel sits to the left, mutation log to the right. */
.mutation-panel {
  right: calc(100% + 12px);
}

.mutation-log {
  left: calc(100% + 12px);
}

.mutation-log__row {
  cursor: pointer;
  user-select: none;
  /* Coloured left border keyed to the affected node type, matching the tree
     tiles (see .bt-tile--*). */
  border-left: 3px solid transparent;
}

.mutation-log__row--composite {
  background: rgba(74, 85, 104, 0.25);
  border-left-color: #718096;
}

.mutation-log__row--action {
  background: rgba(245, 101, 101, 0.15);
  border-left-color: #f56565;
}

.mutation-log__row--condition {
  background: rgba(99, 179, 237, 0.15);
  border-left-color: #63b3ed;
}

.mutation-log__row--value {
  background: rgba(72, 187, 120, 0.15);
  border-left-color: #48bb78;
}

.mutation-log__row:hover {
  filter: brightness(1.4);
}

.mutation-log__json {
  margin: 0;
  padding: 8px 16px;
  background: rgba(0, 0, 0, 0.3);
  color: #a0aec0;
  font-size: 11px;
  line-height: 1.4;
  white-space: pre;
  overflow-x: auto;
}

.mutation-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(74, 85, 104, 0.4);
}

.mutation-panel__title {
  font-size: 14px;
  font-weight: 600;
  color: #e2e8f0;
}

.mutation-panel__list {
  overflow-y: auto;
  padding: 6px 0;
}

.mutation-panel__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 16px;
  font-size: 12px;
  color: #cbd5e0;
}

.mutation-panel__pct {
  color: #718096;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.mutation-panel__pin {
  font-size: 11px;
}

.mutation-log__empty {
  color: #718096;
  font-style: italic;
}

.tree-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(74, 85, 104, 0.4);
}

.tree-modal__title {
  font-size: 15px;
  font-weight: 600;
  color: #e2e8f0;
  margin-right: auto;
}

.tree-modal__dice {
  background: none;
  border: none;
  color: #a0aec0;
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
  margin-right: 8px;
  line-height: 1;
}

.tree-modal__dice:hover {
  color: #e2e8f0;
}

.tree-modal__close {
  background: none;
  border: none;
  color: #a0aec0;
  font-size: 14px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.tree-modal__close:hover {
  color: #e2e8f0;
}

.tree-modal__tabs {
  display: flex;
  gap: 4px;
  padding: 10px 16px 0;
}

.tree-modal__tab {
  background: rgba(45, 55, 72, 0.55);
  border: 1px solid rgba(74, 85, 104, 0.5);
  border-radius: 6px 6px 0 0;
  color: #a0aec0;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 14px;
}

.tree-modal__tab--active {
  color: #e0bf4f;
  border-color: #e0bf4f;
  background: rgba(224, 191, 79, 0.1);
}

/* Behaviour tree view: a stack of colour-coded tiles, each tree level
   indented a little further to the left. */
.bt-view {
  padding: 12px 16px;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

.bt-children {
  margin-left: 16px;
}

/* A vertical line down the left of a composite's children connects the nodes in
   the list, and its style encodes the composite's logic: a solid line for a
   sequence (AND — every child must run), a dashed line for a selector (OR — the
   first succeeding child wins). */
.bt-children--and,
.bt-children--or {
  margin-left: 7px;
  padding-left: 12px;
  border-left: 2px solid #4a5568;
}

.bt-children--or {
  border-left-style: dashed;
}

/* A horizontal stub joins the vertical line to each direct child, ending in a
   small circle notch where it meets the node. */
.bt-children--and > .bt-node,
.bt-children--or > .bt-node {
  position: relative;
}

.bt-children--and > .bt-node::before,
.bt-children--or > .bt-node::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 15px;
  width: 12px;
  border-top: 2px solid #4a5568;
}

.bt-children--and > .bt-node::after,
.bt-children--or > .bt-node::after {
  content: "";
  position: absolute;
  left: -3px;
  top: 12px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4a5568;
}

.bt-tile {
  display: inline-flex;
  flex-direction: column;
  align-items: stretch;
  margin: 2px 0;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-left-width: 3px;
}

.bt-tile__header {
  display: flex;
  align-items: center;
  gap: 6px;
}

.bt-tile--collapsible > .bt-tile__header {
  cursor: pointer;
  user-select: none;
}

/* Data values nest inside their parent node's tile rather than trailing below
   it, so a node's params read as part of the node. */
.bt-tile__values {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin-top: 4px;
  padding-left: 6px;
  border-left: 1px solid rgba(255, 255, 255, 0.1);
}

.bt-tile__toggle {
  color: #718096;
  font-size: 9px;
  width: 10px;
  text-align: center;
}

.bt-tile__param {
  color: #a0aec0;
}

.bt-tile__param::after {
  content: ":";
  color: #718096;
}

.bt-tile__label {
  font-weight: 600;
  color: #e2e8f0;
}

.bt-tile--highlighted {
  box-shadow: 0 0 0 2px #f6e05e;
}

.bt-tile__muts {
  margin-left: 4px;
  padding: 0 5px;
  background: rgba(74, 85, 104, 0.4);
  border: none;
  border-radius: 4px;
  color: #cbd5e0;
  font-size: 10px;
  line-height: 1.5;
  cursor: pointer;
}

.bt-tile__muts:hover {
  background: rgba(74, 85, 104, 0.8);
  color: #e2e8f0;
}

.bt-tile__badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.3);
  color: #feb2b2;
}

.bt-tile__meta {
  font-size: 10px;
  color: #718096;
}

.bt-tile--composite {
  background: rgba(74, 85, 104, 0.25);
  border-left-color: #718096;
}

.bt-tile--composite .bt-tile__label {
  color: #a0aec0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 11px;
}

.bt-tile--action {
  background: rgba(245, 101, 101, 0.15);
  border-left-color: #f56565;
}

.bt-tile--condition {
  background: rgba(99, 179, 237, 0.15);
  border-left-color: #63b3ed;
}

.bt-tile--value {
  background: rgba(72, 187, 120, 0.15);
  border-left-color: #48bb78;
}

.matchup-vs-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.matchup-vs {
  font-family: "Cinzel", serif;
  font-weight: bold;
  font-size: 18px;
  color: #e0bf4f;
  text-shadow: 1px 1px 1px #000;
}

.matchup-swap {
  background: none;
  border: 1px solid rgba(74, 85, 104, 0.5);
  border-radius: 4px;
  color: #718096;
  font-size: 14px;
  cursor: pointer;
  padding: 2px 6px;
  line-height: 1;
  transition: color 0.15s, border-color 0.15s;
}

.matchup-swap:hover {
  color: #e2e8f0;
  border-color: rgba(160, 174, 192, 0.6);
}

/* PlayingAs */
.playing-as-label {
  display: block;
  text-transform: uppercase;
  font-weight: bold;
  font-size: 12px;
}
