:root {
  --void: #04080b;
  --panel: #0a1014;
  --line: #1c3039;
  --line-hi: #335866;
  --edge: #5fd0e0;
  --ink: #d5ecf1;
  --dim: #6f8f9a;
  --up: #86d94a;
  --down: #f2594b;
  --cut: 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100dvh;
  padding: 14px;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  gap: 10px;
  /* A faint survey grid, like a map seen from strategic zoom. */
  background:
    radial-gradient(circle at 1px 1px, #0f1d24 1px, transparent 1.5px) 0 0 / 24px 24px,
    var(--void);
  color: var(--ink);
  font-family: Oxanium, ui-sans-serif, system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
}

/* Two cut corners and a one pixel steel edge. The edge is the element's own
   background showing around an inset fill, since a border cannot follow a
   clip-path. */
.panel {
  position: relative;
  /* The edge catches light at the cut corners. */
  background: linear-gradient(135deg, var(--edge), var(--line) 110px, var(--line) calc(100% - 110px), var(--line-hi));
  clip-path: polygon(var(--cut) 0, 100% 0, 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, 0 100%, 0 var(--cut));
}

.panel::before {
  content: "";
  position: absolute;
  inset: 1px;
  background: var(--panel);
  clip-path: inherit;
}

.panel > * {
  position: relative;
}

header {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

#readouts {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.readout {
  min-width: 300px;
  padding: 10px 18px 11px 22px;
  display: grid;
  grid-template: "art name up" auto "art total down" auto "links goal goal" auto / auto 1fr auto;
  column-gap: 14px;
  align-items: baseline;
}

/* Steam's small capsule, 231 by 87, shown at half size. */
.readout .art {
  grid-area: art;
  align-self: center;
  width: 116px;
  height: auto;
  margin-right: 2px;
  outline: 1px solid var(--line);
}

.readout .pip {
  position: absolute;
  inset: 1px auto 1px 1px;
  width: 5px;
  background: var(--c);
  box-shadow: 0 0 16px var(--c);
}

.readout .name {
  grid-area: name;
  font-size: 13px;
  letter-spacing: 0.04em;
  color: var(--dim);
}

.readout .total {
  grid-area: total;
  font-size: 34px;
  font-weight: 600;
  line-height: 1.05;
  text-shadow: 0 0 24px color-mix(in srgb, var(--c) 55%, transparent);
}

.readout .total b {
  font-weight: inherit;
}

.readout .total small {
  margin-left: 8px;
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--dim);
}

/* Brand marks drawn as masks so they take the page's ink, not their own. */
.readout .links {
  grid-area: links;
  align-self: end;
  display: flex;
  /* Five marks fit exactly under the 116px capsule. */
  gap: 9px;
}

.readout .links a {
  width: 16px;
  height: 16px;
  background: var(--dim);
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
}

.readout .links a:hover,
.readout .links a:focus-visible {
  outline: 0;
  background: var(--ink);
}

/* One cell per milestone, like a storage bar cut into tiers. */
.readout .tiers {
  grid-area: goal;
  margin-top: 10px;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
}

.readout .tier {
  display: grid;
  gap: 4px;
}

.readout .tier .track {
  height: 4px;
  background: var(--line);
}

.readout .tier .track i {
  display: block;
  height: 100%;
  background: var(--c);
}

.readout .tier .label {
  font-size: 11px;
  letter-spacing: 0.04em;
  text-align: right;
  color: var(--dim);
}

.readout .tier.big .track {
  background: var(--line-hi);
}

.readout .tier.big .label {
  color: var(--ink);
}

.readout .up,
.readout .down {
  min-width: 44px;
  font-size: 15px;
  font-weight: 600;
  text-align: right;
}

.readout .up {
  grid-area: up;
  color: var(--up);
}

/* Removals stay neutral: red is a game's color here, not a warning. */
.readout .down {
  grid-area: down;
  color: var(--dim);
}

#when {
  margin-left: auto;
  padding-bottom: 5px;
  font-size: 13px;
  letter-spacing: 0.04em;
  color: var(--dim);
  white-space: nowrap;
}

main {
  min-height: 0;
  padding: 10px 6px 6px 8px;
  display: flex;
  flex-direction: column;
}

/* The chart is sized from this box, so the box must never size from the chart. */
#totals {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.strip {
  height: 70px;
  border-top: 1px solid var(--line);
}

/* Where new wishlists came from. One group per breakdown, and inside each
   group one column per game, largest first. */
#where {
  padding: 12px 20px 14px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 18px 44px;
  font-size: 13px;
  color: var(--dim);
}

#where .group {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  align-items: start;
  gap: 0 20px;
}

#where[hidden],
#settings[hidden],
#ranges[hidden] {
  display: none;
}

.where .row {
  padding: 3px 0 5px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--ink);
  background: linear-gradient(var(--c), var(--c)) left bottom / var(--w) 2px no-repeat;
}

.where .row b {
  font-weight: 600;
}

.u-cursor-x {
  border-right: 1px solid color-mix(in srgb, var(--edge) 60%, transparent) !important;
}

/* Labels that follow the pointer along the chart. */
.tip {
  position: absolute;
  z-index: 1;
  transform: translateY(-50%);
  padding: 3px 9px 2px;
  display: flex;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--c);
  font-size: 13px;
  white-space: nowrap;
  pointer-events: none;
}

.tip[hidden] {
  display: none;
}

.tip.flip {
  transform: translate(-100%, -50%);
}

.tip span {
  color: var(--dim);
}

.tip b {
  font-weight: 600;
}

.tip.date {
  --c: var(--line-hi);
  transform: translateX(-50%);
  font-size: 12px;
  color: var(--dim);
}

/* The controls sit on the chart's top edge, like tabs on a folder. */
#bar {
  position: relative;
  margin-bottom: -10px;
  padding: 0 14px 0 18px;
  display: flex;
  align-items: flex-end;
  gap: 14px;
}

footer {
  display: flex;
}

#settings-toggle {
  padding: 6px 20px 5px;
  border: 0;
  background: var(--line);
  color: var(--dim);
  font: inherit;
  font-size: 13px;
  letter-spacing: 0.04em;
  cursor: pointer;
  clip-path: polygon(9px 0, calc(100% - 9px) 0, 100% 100%, 0 100%);
}

#settings-toggle:hover,
#settings-toggle[aria-expanded="true"] {
  color: var(--ink);
}

#settings-toggle:focus-visible {
  outline: 0;
  background: var(--ink);
  color: var(--void);
}

#settings {
  position: absolute;
  right: 14px;
  top: calc(100% + 8px);
  z-index: 2;
  padding: 12px 18px;
  display: grid;
  gap: 8px;
  font-size: 13px;
}

#settings label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

#settings input {
  appearance: none;
  width: 14px;
  height: 14px;
  margin: 0;
  border: 1px solid var(--line-hi);
  background: var(--void);
  cursor: pointer;
}

#settings input:checked {
  border-color: var(--edge);
  background: var(--edge);
  box-shadow: inset 0 0 0 2px var(--void);
}

#settings input:focus-visible {
  outline: 1px solid var(--ink);
  outline-offset: 2px;
}

#ranges {
  display: flex;
  gap: 2px;
}

#ranges button {
  padding: 6px 20px 5px;
  border: 0;
  background: var(--line);
  color: var(--dim);
  font: inherit;
  font-size: 13px;
  letter-spacing: 0.04em;
  cursor: pointer;
  clip-path: polygon(9px 0, calc(100% - 9px) 0, 100% 100%, 0 100%);
}

#ranges button:hover {
  color: var(--ink);
}

#ranges button[aria-pressed="true"] {
  background: linear-gradient(var(--edge) 0 2px, var(--line-hi) 2px);
  color: var(--ink);
}

#ranges button:focus-visible {
  outline: 0;
  background: var(--ink);
  color: var(--void);
}

#status {
  margin: 0 0 0 auto;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--dim);
  text-align: right;
}

#status .bad {
  color: var(--down);
}

@media (max-width: 640px) {
  body {
    height: auto;
    grid-template-rows: auto auto auto auto auto;
    padding: 10px;
  }

  header {
    flex-direction: column;
    align-items: stretch;
  }

  .readout {
    flex: 1 1 100%;
  }

  #totals {
    flex: none;
    height: 320px;
  }
}
