.pb {
  --row: 36px;
  --name: 200px;
  position: relative;
  width: 540px;
  height: 540px;
  overflow: hidden;
  background: #010402;
  /* the page's own text is the signal source: the tube draws it, so it stays unpainted here */
  color: transparent;
  /* 25.6 px puts one row of the face's dots on each 2 px scan line */
  font: 400 25.6px/1 "VT323", monospace;
  font-kerning: none;
  font-variant-ligatures: none;
  -webkit-user-select: none;
  user-select: none;
  cursor: default;
}

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

.pb i {
  display: block;
}

.pb-glass {
  position: absolute;
  inset: 0;
  width: 540px;
  height: 540px;
  pointer-events: none;
  /* the supply is never quite steady: the whole field breathes a little */
  animation: pb-supply 4.3s linear infinite;
}

@keyframes pb-supply {
  0%, 100% { opacity: 1; }
  9% { opacity: 0.972; }
  21% { opacity: 0.992; }
  34% { opacity: 0.965; }
  47% { opacity: 1; }
  58% { opacity: 0.98; }
  63% { opacity: 0.958; }
  76% { opacity: 0.995; }
  88% { opacity: 0.975; }
}

/* mains ripple: a broad, faint band that climbs the picture */
.pb::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 1080px;
  background: linear-gradient(
    to bottom,
    rgba(120, 255, 160, 0) 0px,
    rgba(120, 255, 160, 0.028) 150px,
    rgba(120, 255, 160, 0) 300px,
    rgba(120, 255, 160, 0) 540px,
    rgba(120, 255, 160, 0.028) 690px,
    rgba(120, 255, 160, 0) 840px
  );
  pointer-events: none;
  animation: pb-ripple 5.6s linear infinite;
}

@keyframes pb-ripple {
  from { transform: translateY(0); }
  to { transform: translateY(-540px); }
}

.pb-grid {
  position: absolute;
  top: 22px;
  left: 28px;
  right: 28px;
  outline: 0;
}

.pb-head,
.pb-row {
  display: grid;
  grid-template-columns: var(--name) 1fr;
}

.pb-head {
  height: 56px;
}

.pb-corner {
  display: flex;
  align-items: flex-start;
  height: 56px;
  padding: 0 0 0 4px;
  font-weight: 400;
  text-align: left;
}

.pb-corner span {
  line-height: 24px;
}

.pb-time {
  position: static;
  font-weight: 400;
}

/* The axis and the mark span the plot: from the header down to the last row that shows. */
.pb-axis,
.pb-marks {
  position: absolute;
  top: 0;
  height: calc(56px + var(--pb-rows) * var(--row));
  pointer-events: none;
}

.pb-axis,
.pb-marks {
  left: var(--name);
  right: 0;
}

.pb-tick {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--waterfall-tick);
  width: 0;
}

.pb-tick-label {
  position: absolute;
  top: 0;
  left: 0;
  line-height: 24px;
  white-space: nowrap;
  transform: translateX(-50%);
}

.pb-tick-line {
  position: absolute;
  top: 56px;
  bottom: 0;
  left: -1px;
  width: 2px;
}

.pb-mark {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--waterfall-mark);
  width: 0;
}

.pb-mark-label {
  position: absolute;
  top: 26px;
  left: -1px;
  padding: 0 8px;
  line-height: 24px;
  white-space: nowrap;
}

.pb-mark-line {
  position: absolute;
  top: 28px;
  bottom: 0;
  left: -1px;
  width: 2px;
}

.pb-row {
  position: relative;
  height: var(--row);
  outline: 0;
}

.pb-name {
  position: relative;
  display: flex;
  align-items: center;
  height: var(--row);
  padding-left: calc((var(--waterfall-level) - 1) * 10px);
  font-weight: 400;
  text-align: left;
  white-space: nowrap;
  outline: 0;
}

.pb-toggle,
.pb-leaf {
  flex: none;
  width: 18px;
  height: var(--row);
}

.pb-toggle {
  display: grid;
  place-items: center;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  outline: 0;
  cursor: pointer;
}

.pb-toggle i {
  justify-self: start;
  width: 12px;
  height: 14px;
}

.pb-label {
  line-height: var(--row);
}

.pb-bar {
  position: relative;
  height: var(--row);
  outline: 0;
}

.pb-fill {
  position: absolute;
  top: 10px;
  bottom: 10px;
  left: var(--waterfall-start);
  width: var(--waterfall-size);
}

.pb-tally {
  position: absolute;
  top: 0;
  left: calc(var(--waterfall-start) + var(--waterfall-size) + 4px);
  padding: 0 4px;
  line-height: var(--row);
  white-space: nowrap;
}

.pb-status {
  position: absolute;
  left: 28px;
  right: 28px;
  top: 446px;
  display: grid;
  grid-template-columns: 1fr auto;
  row-gap: 0;
  padding-top: 10px;
  line-height: 24px;
  white-space: nowrap;
}

.pb-status span {
  padding: 0 4px;
}

.pb-status-rule {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
}

.pb-status-took,
.pb-status-tally {
  justify-self: end;
}

.pb-status-name,
.pb-status-when {
  justify-self: start;
}

@media (prefers-reduced-motion: reduce) {
  .pb-glass,
  .pb::after {
    animation: none;
  }
}

/* Without the tube (no WebGL2) the grid paints itself: the same face, the same
   three levels, the same inverse cursor, lit by the stylesheet alone. */
.pb[data-plain] {
  --dim: #2f9a56;
  --norm: #63e58c;
  --bright: #b4ffcb;
  --ground: #010402;
}

.pb[data-plain] .pb-glass {
  display: none;
}

/* scan lines and the fall-off toward the corners */
.pb[data-plain]::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  background:
    radial-gradient(ellipse at 50% 50%, rgba(0, 0, 0, 0) 55%, rgba(0, 0, 0, 0.55) 100%),
    repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0) 0 1px, rgba(0, 0, 0, 0.3) 1px 2px);
  pointer-events: none;
}

.pb[data-plain] [data-ink] {
  color: var(--norm);
  text-shadow: 0 0 5px rgba(70, 255, 130, 0.45);
}

.pb[data-plain] [data-ink="dim"] {
  color: var(--dim);
}

.pb[data-plain] [data-ink="bright"] {
  color: var(--bright);
}

.pb[data-plain] [data-ruled] {
  text-decoration: underline 2px;
  text-underline-offset: 4px;
}

.pb[data-plain] [data-draw] {
  --ink: var(--norm);
}

.pb[data-plain] [data-draw][data-level="dim"] {
  --ink: var(--dim);
}

.pb[data-plain] [data-draw][data-level="bright"] {
  --ink: var(--bright);
}

.pb[data-plain] [data-draw="bar"],
.pb[data-plain] [data-draw="rule"] {
  background: var(--ink);
  box-shadow: 0 0 6px rgba(70, 255, 130, 0.35);
}

.pb[data-plain] [data-draw="span"] {
  border-inline: 2px solid var(--ink);
  background: linear-gradient(var(--ink), var(--ink)) center / 100% 2px no-repeat;
}

.pb[data-plain] [data-draw="dots"] {
  background: repeating-linear-gradient(to bottom, var(--ink) 0 2px, transparent 2px 4px);
}

.pb[data-plain] [data-draw="dash"] {
  background: repeating-linear-gradient(to bottom, var(--ink) 0 6px, transparent 6px 8px);
}

.pb[data-plain] [data-draw="open"] {
  background: var(--ink);
  clip-path: polygon(0 22%, 100% 22%, 50% 78%);
}

.pb[data-plain] [data-draw="closed"] {
  background: var(--ink);
  clip-path: polygon(17% 0, 17% 100%, 80% 50%);
}

/* text written over the plot blanks the rules behind it */
.pb[data-plain] [data-clear] {
  background: var(--ground);
}

.pb[data-plain] .pb-row:hover {
  background: linear-gradient(#0d2417, #0d2417) 0 2px / 100% calc(100% - 4px) no-repeat;
}

.pb[data-plain] .pb-row:hover [data-clear] {
  background: linear-gradient(#0d2417, #0d2417) 0 2px / 100% calc(100% - 4px) no-repeat;
}

/* the cursor: the whole row in inverse video, or one cell when a cell has it */
.pb[data-plain] .pb-row:focus,
.pb[data-plain] .pb-row:has(.pb-toggle:focus),
.pb[data-plain] .pb-name:focus,
.pb[data-plain] .pb-bar:focus {
  background: linear-gradient(#7dffa5, #7dffa5) 0 2px / 100% calc(100% - 4px) no-repeat;
}

.pb[data-plain] .pb-row:focus [data-ink],
.pb[data-plain] .pb-row:has(.pb-toggle:focus) [data-ink],
.pb[data-plain] .pb-name:focus [data-ink],
.pb[data-plain] .pb-bar:focus [data-ink] {
  color: var(--ground);
  text-shadow: none;
  background: none;
}

.pb[data-plain] .pb-row:focus [data-draw],
.pb[data-plain] .pb-row:has(.pb-toggle:focus) [data-draw],
.pb[data-plain] .pb-name:focus [data-draw],
.pb[data-plain] .pb-bar:focus [data-draw] {
  --ink: var(--ground);
  box-shadow: none;
}
