/* Buttons */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: var(--control-md);
  padding: 0 var(--space-5);
  border: 0;
  border-radius: var(--radius-md);
  background: var(--surface-3);
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.button:hover {
  filter: brightness(1.1);
}

.button--primary {
  background: var(--accent);
  color: var(--on-accent);
}

.button--danger {
  background: var(--danger-fill);
  color: var(--on-accent);
}

.button--lg {
  height: var(--control-lg);
  padding: 0 var(--space-6);
  font-size: 16px;
}

.button--sm {
  height: 32px;
  padding: 0 var(--space-3);
  border-radius: 8px;
  font-size: 12px;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: var(--control-md);
  height: var(--control-md);
  padding: 0;
  border: 0;
  border-radius: var(--radius-md);
  background: var(--surface-1);
  color: var(--ink);
  cursor: pointer;
}

/* The wordmark comes in white and in ink; the page's theme shows the one that reads on it. */
:root:not([data-theme="light"]) .logo--on-light,
:root[data-theme="light"] .logo--on-dark {
  display: none;
}

/* A mark drawn in white turns to ink on a light page, but not on a dark island there. */
:root[data-theme="light"] .mark--white {
  filter: invert(1);
}

:root[data-theme="light"] .theme-dark .mark--white {
  filter: none;
}

/* The theme switch shows where a press leads: the sun from a dark page, the moon from a light one. */
.theme-toggle__to-dark,
:root[data-theme="light"] .theme-toggle__to-light {
  display: none;
}

:root[data-theme="light"] .theme-toggle__to-dark {
  display: block;
}

.icon-button--ghost {
  background: transparent;
  color: var(--ink-muted);
}

.icon-button--ghost:hover {
  color: var(--ink);
}

/* The shelf arrows: small and round. */
.icon-button--sm {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
}

.icon-button--sm:disabled {
  opacity: 0.4;
  cursor: default;
}

.icon-button--lg {
  width: var(--control-lg);
  height: var(--control-lg);
  color: var(--ink-muted);
}

.avatar {
  flex: none;
  width: var(--control-md);
  height: var(--control-md);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}

.text-link {
  color: var(--ink-muted);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}

.text-link:hover {
  color: var(--ink);
}

/* Surfaces and headings */
.card {
  padding: var(--space-5);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

/* A grey icon may lead the title. */
.section-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  line-height: 1.3;
}

.section-title > .icon {
  flex: none;
  color: var(--ink-muted);
}

.overline {
  color: var(--ink-muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.live-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--win);
}

.live-count {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--ink-muted);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.kbd {
  padding: 3px var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
}

/* Search */
.search {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  height: var(--control-md);
  padding: 0 var(--space-3) 0 var(--space-4);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--field);
  color: var(--ink-muted);
}

.search:focus-within {
  border-color: var(--focus);
}

/* Segmented controls and chips */
.segmented {
  display: inline-flex;
  gap: var(--space-1);
  max-width: 100%;
  padding: var(--space-1);
  border-radius: 13px;
  background: var(--track);
}

.segmented button {
  height: 36px;
  padding: 0 var(--space-4);
  border: 0;
  border-radius: var(--radius-tab);
  background: transparent;
  color: var(--ink-muted);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.segmented button[aria-pressed="true"],
.segmented button[aria-selected="true"] {
  background: var(--selected);
  color: var(--ink);
}

.segmented--square {
  border-radius: var(--radius-md);
}

.segmented--square button {
  border-radius: 8px;
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.filter-chips button {
  height: 32px;
  padding: 0 var(--space-3);
  border: 0;
  border-radius: 8px;
  background: var(--surface-1);
  color: var(--ink-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.filter-chips button[aria-pressed="true"],
.filter-chips button[aria-selected="true"] {
  background: var(--selected);
  color: var(--ink);
}

/* Tables */
.table-well {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  background: var(--surface-0);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.data-table th,
.data-table td {
  padding: var(--space-3) 0;
  color: var(--ink-muted);
  text-align: left;
  white-space: nowrap;
}

.data-table th {
  font-size: 13px;
  font-weight: 600;
}

.data-table :is(th, td) + :is(th, td) {
  padding-left: var(--space-4);
}

.data-table :is(th, td):first-child {
  padding-left: var(--space-5);
}

.data-table :is(th, td):last-child {
  padding-right: var(--space-5);
}

.data-table tbody tr:nth-child(odd) {
  background: var(--row-alt);
}

.data-table td.num {
  color: var(--ink);
}

.data-table .num {
  text-align: right;
}

.data-table .data-table__game {
  color: var(--ink);
  font-weight: 600;
}

.data-table .is-win {
  color: var(--win);
  font-weight: 700;
}

.data-table .is-loss {
  color: var(--ink-muted);
  font-weight: 700;
}

.data-table--live {
  min-width: 640px;
}

/* Progress */
.progress {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.progress__track {
  flex: 1;
  height: 6px;
  overflow: hidden;
  border-radius: var(--radius-full);
  background: var(--surface-0);
}

.progress__fill {
  display: block;
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--accent);
}

/* A hint that opens above its trigger on hover or focus, its arrow over the trigger. It starts a little
   left of the trigger, so a trigger near a panel's left edge keeps it on screen. */
.tip {
  position: relative;
  display: inline-flex;
}

.tip__trigger {
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: var(--radius-full);
  background: none;
  color: var(--ink-muted);
  cursor: help;
}

.tip__trigger:hover,
.tip__trigger:focus-visible {
  color: var(--ink);
}

.tip__bubble {
  position: absolute;
  bottom: calc(100% + 10px);
  left: -56px;
  z-index: 20;
  width: max-content;
  max-width: min(336px, calc(100vw - 32px));
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  background: var(--surface-3);
  box-shadow: 0 8px 24px rgb(0 0 0 / calc(0.35 * var(--shade)));
  color: var(--ink);
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
  text-align: start;
  white-space: normal;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.15s, visibility 0.15s;
}

.tip__bubble::after {
  position: absolute;
  top: 100%;
  left: 58px;
  border: 6px solid transparent;
  border-top-color: var(--surface-3);
  content: "";
}

.tip:hover .tip__bubble,
.tip:focus-within .tip__bubble {
  opacity: 1;
  visibility: visible;
}

.progress__count {
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Switch */
.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: var(--control-md);
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.switch__track {
  display: flex;
  width: 44px;
  height: 26px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  background: var(--surface-0);
}

.switch__thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--ink-muted);
}

/* Language select */
.language-select {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--ink-muted);
}

.language-select__label {
  display: flex;
}

.language-select__input {
  height: 36px;
  padding: 0 var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-1);
  color: var(--ink);
  font-size: 14px;
}

/* Game tile */
.tile {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
  border-radius: var(--radius-lg);
  color: var(--ink-muted);
  text-decoration: none;
}

.tile__art {
  position: relative;
  display: flex;
  align-items: flex-start;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  transition: transform 0.15s ease;
}

.tile:hover .tile__art {
  transform: translateY(-4px);
}

.tile__image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tile__label {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-8) var(--space-3) var(--space-3);
  background: linear-gradient(to top, rgb(0 0 0 / 0.72), transparent);
  color: #FFFFFF;
}

.tile__name {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 800;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.tile__tag {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.85;
}

.tile__meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 20px;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.tile--blue { background-color: var(--tile-blue); color: var(--on-tile-light); }
.tile--violet { background-color: var(--tile-violet); color: var(--on-tile-light); }
.tile--coral { background-color: var(--tile-coral); color: var(--on-tile-light); }
.tile--teal { background-color: var(--tile-teal); color: var(--on-tile-dark); }
.tile--amber { background-color: var(--tile-amber); color: var(--on-tile-dark); }
.tile--mint { background-color: var(--tile-mint); color: var(--on-tile-dark); }

/* A list page's heading: a 150px dark band with 12px corners, the title 24px bold on the left and the
   art filling the right, fading in from the band. */
.page-banner {
  position: relative;
  display: flex;
  align-items: center;
  height: 150px;
  overflow: hidden;
  border-radius: 12px;
  background: var(--surface-2);
}

.page-banner__text {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: 0 var(--space-4);
}

.page-banner__title {
  margin: 0;
  color: var(--ink);
  font-size: 24px;
  font-weight: 700;
  line-height: 36px;
}

.page-banner__art {
  position: absolute;
  top: 0;
  right: 0;
  width: 55%;
  height: 100%;
  object-fit: cover;
  mask-image: linear-gradient(90deg, transparent, #000 30%);
}

/* The challenges' numbers, in one line. */
.page-banner__stats {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-3);
  margin: 0;
  color: var(--ink-muted);
  font-size: 14px;
}

.page-banner__stats div {
  display: flex;
  gap: var(--space-1);
}

.page-banner__stats div + div::before {
  margin-right: var(--space-2);
  color: var(--line);
  content: "|";
}

.page-banner__stats dd {
  margin: 0;
  color: var(--ink);
  font-weight: 700;
}

@media (max-width: 767px) {
  .section-title {
    font-size: 20px;
  }

  /* 125px tall, the title at 24px. */
  .page-banner {
    height: 125px;
  }

  .page-banner__title {
    font-size: 24px;
  }

  .page-banner__art {
    width: 65%;
  }
}
