:root {
  color-scheme: dark;
  --ink: #e9eaec;
  --dim: #8b9099;
  --panel: #15171b;
  --edge: #262a31;
  --below: 13.5rem;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: clamp(14px, 1.1vw, 28px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: #000;
  color: var(--ink);
}

main {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
}

/* The picture: as large as the screen allows above the controls. */
.stage {
  position: relative;
  width: min(100vw, calc((100vh - var(--below)) * 16 / 9));
  aspect-ratio: 16 / 9;
  background: #000;
  overflow: hidden;
}
@supports not (aspect-ratio: 1) {
  .stage { height: calc(min(100vw, calc((100vh - var(--below)) * 16 / 9)) * 9 / 16); }
}

.stage video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  z-index: 0;
}
.stage video.on { z-index: 1; }

/* The last picture, held while a single player loads another stream. */
.stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  z-index: 2;
}

.bigplay {
  position: absolute;
  z-index: 3;
  inset: 0;
  margin: auto;
  width: 5.5rem;
  height: 5.5rem;
  border-radius: 50%;
  border: 0;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  cursor: pointer;
}
.bigplay svg { width: 55%; height: 55%; fill: currentColor; }
.bigplay .i-replay, .bigplay.replay .i-play { display: none; }
.bigplay.replay .i-replay { display: inline; }

.notice {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 1rem;
  max-width: calc(100% - 2rem);
  padding: .6rem .75rem .6rem 1rem;
  border-radius: .5rem;
  background: rgba(16, 17, 20, .92);
  border: 1px solid var(--edge);
}
.notice p { margin: 0; font-size: .95rem; }
.notice button {
  flex: none;
  font: inherit;
  font-size: .9rem;
  color: var(--ink);
  background: #2a2e36;
  border: 1px solid #3a3f49;
  border-radius: .35rem;
  padding: .45rem .8rem;
  cursor: pointer;
}
[hidden] { display: none !important; }

/* Transport row */
.bar {
  display: flex;
  align-items: center;
  gap: .5rem;
  width: min(100vw, calc((100vh - var(--below)) * 16 / 9));
  padding: .5rem .75rem 0;
}
.ctl {
  flex: none;
  width: 2.5rem;
  height: 2.5rem;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: .4rem;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
.ctl svg { width: 1.5rem; height: 1.5rem; fill: currentColor; }
.ctl:hover { background: #1c1f24; }
#play .i-pause, #play.playing .i-play { display: none; }
#play.playing .i-pause { display: block; }
#mute .i-muted, #mute.muted .i-sound { display: none; }
#mute.muted .i-muted { display: block; }

#seek {
  flex: 1;
  min-width: 4rem;
  accent-color: #c9ccd2;
  height: 2.5rem;
  background: transparent;
}
.time {
  flex: none;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
  font-size: .85rem;
  min-width: 6.5em;
  text-align: right;
}

/* The view switch: two halves of one control */
.views {
  display: flex;
  margin: .55rem 0 0;
  padding: 3px;
  border: 1px solid var(--edge);
  border-radius: .55rem;
  background: var(--panel);
}
.views button {
  font: inherit;
  font-size: .95rem;
  min-width: 8.5rem;
  min-height: 2.5rem;
  padding: .35rem 1rem;
  border: 0;
  border-radius: .4rem;
  background: transparent;
  color: var(--dim);
  cursor: pointer;
}
.views button:hover { color: var(--ink); }
.views button[aria-pressed="true"] {
  background: #e9eaec;
  color: #0b0c0e;
  font-weight: 650;
}

/* The strip of boards */
.strip {
  width: min(100vw, calc((100vh - var(--below)) * 16 / 9));
  max-width: 100vw;
}
.strip ul {
  position: relative;
  list-style: none;
  margin: 0;
  padding: .6rem .75rem 1rem;
  display: flex;
  gap: .5rem;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
}
.strip li { flex: none; scroll-snap-align: start; }
/* Programme view: the strip keeps its room, so the picture does not move. */
.strip.off { visibility: hidden; }

.chip {
  --c: #777;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 7.5rem;
  padding: 0;
  font: inherit;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: .4rem;
  overflow: hidden;
  cursor: pointer;
  text-align: left;
}
.chip .sw {
  display: block;
  height: 2.6rem;
  background: var(--c);
  position: relative;
}
.chip .sw img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: .35rem;
}
.chip .nm {
  display: block;
  padding: .4rem .55rem .5rem;
  font-size: .9rem;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chip .pg {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: 0;
  background: var(--c);
}
.chip:hover { border-color: #3a3f49; }

/* One clear active state */
.chip[aria-pressed="true"] {
  border-color: var(--c);
  box-shadow: inset 0 0 0 2px var(--c);
  background: #1d2026;
}
.chip[aria-pressed="true"] .nm { font-weight: 650; }
.chip[aria-pressed="true"] .sw::after {
  content: "";
  position: absolute;
  right: .45rem;
  bottom: .45rem;
  width: .55rem;
  height: .55rem;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, .35);
}

/* Quiet progress while a board is on its way */
.chip.is-pending { border-color: var(--c); background: #1d2026; }
.chip.is-pending .pg { animation: pg 1.6s ease-in-out infinite; }
@keyframes pg {
  0% { left: 0; width: 30%; }
  50% { left: 15%; width: 70%; }
  100% { left: 100%; width: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .chip.is-pending .pg { animation: none; width: 100%; opacity: .6; }
}
.chip.is-failed .nm { color: var(--dim); }
.chip.is-failed .sw { opacity: .45; }

.chip:focus-visible, .ctl:focus-visible, .bigplay:focus-visible, .views button:focus-visible,
.notice button:focus-visible, #seek:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 2px;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (max-width: 600px) {
  :root { --below: 0px; }
  .stage, .bar, .strip { width: 100vw; }
  .chip { width: 6.25rem; }
  .views button { min-width: 0; flex: 1; }
  .views { width: calc(100vw - 1.5rem); }
  .chip .sw { height: 2.2rem; }
}
