:root {
  --bg: #000;
  --ink: #fff;
  --dim: rgba(255, 255, 255, 0.56);
  --line: rgba(255, 255, 255, 0.16);
  --tile: #0b0b0b;
  --gap: 3px;
  --display: 'Anton', Impact, sans-serif;
  --body: 'Inter', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; background: var(--bg); color: var(--ink); }
body {
  font-family: var(--body);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

/* The wall: 4 x 3 screens, the middle two are the title. */
.wall {
  height: 100dvh;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: var(--gap);
  padding: var(--gap);
}

.tile {
  position: relative;
  overflow: hidden;
  background: var(--tile);
  cursor: pointer;
}
.tile video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.4s ease;
}
.tile.live video { opacity: 1; }

/* No clip yet: TV static. */
.tile .static {
  position: absolute;
  inset: -50%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.1' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1.6 -0.35'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: 0.22;
  animation: static 0.5s steps(5) infinite;
}
.tile.live .static { display: none; }
@keyframes static {
  0% { transform: translate(0, 0); }
  20% { transform: translate(-7%, 4%); }
  40% { transform: translate(5%, -9%); }
  60% { transform: translate(-3%, 8%); }
  80% { transform: translate(9%, 2%); }
  100% { transform: translate(0, 0); }
}

.tile .label {
  position: absolute;
  left: 12px;
  bottom: 10px;
  right: 40px;
  font: 500 11px/1.3 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9), 0 0 8px rgba(0, 0, 0, 0.7);
  color: var(--ink);
  white-space: pre;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tile .sound {
  position: absolute;
  right: 10px;
  bottom: 8px;
  width: 20px;
  height: 20px;
  opacity: 0;
  transition: opacity 0.2s ease;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.8));
}
.tile.live:hover .sound { opacity: 0.6; }
.tile.loud .sound { opacity: 1; }
.tile.loud::after {
  content: '';
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 0 2px var(--ink);
  pointer-events: none;
}

/* Title screen in the middle. */
.title {
  grid-column: 2 / 4;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 16px;
  background: var(--bg);
}
/* The name is cut out of black: the clips play through the letters. */
.marquee {
  position: relative;
  isolation: isolate;
  background: var(--ink);
}
.marquee video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: brightness(1.25) contrast(1.1) saturate(1.1);
}
.name {
  position: relative;
  padding: 0.04em 0.02em 0;
  background: var(--bg);
  color: var(--ink);
  mix-blend-mode: multiply;
  font: 400 clamp(72px, min(17vh, 15vw), 240px)/0.9 var(--display);
  letter-spacing: 0.01em;
}
/* Everything under the name lines up to the edges of the word. */
.lockup {
  display: inline-flex;
  flex-direction: column;
  align-items: stretch;
}
.sub {
  margin-top: 14px;
  font: 500 13px/1 var(--mono);
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

.bar {
  margin-top: 18px;
  display: flex;
  gap: 8px;
  height: 56px;
}
.ca, .scan-btn {
  display: inline-flex;
  align-items: center;
  height: 100%;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}
.ca {
  flex: 1;
  min-width: 0;
  gap: 12px;
  padding: 0 18px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  font: 500 14px/1 var(--mono);
}
.ca:not(:disabled):hover { background: rgba(255, 255, 255, 0.06); }
.ca:disabled { cursor: default; }
.ca-label { color: var(--dim); letter-spacing: 0.16em; }
.ca-value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ca .copy { width: 16px; height: 16px; margin-left: auto; flex: none; color: var(--dim); }
.ca:not(:disabled):hover .copy { color: var(--ink); }
.ca:disabled .copy { opacity: 0.4; }
.scan-btn {
  flex: 1;
  justify-content: center;
  gap: 12px;
  padding: 0 22px;
  background: var(--ink);
  color: var(--bg);
  font: 400 22px/1 var(--display);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.scan-btn svg { width: 18px; height: 18px; }
.scan-btn:hover { background: rgba(255, 255, 255, 0.86); }
.scan-btn:active { transform: scale(0.98); }

/* Popup buttons. */
.btn {
  height: 48px;
  display: inline-flex;
  align-items: center;
  padding: 0 24px;
  background: var(--ink);
  color: var(--bg);
  font: 400 19px/1 var(--display);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}
.btn:hover { background: rgba(255, 255, 255, 0.86); }
.btn.ghost { background: none; color: var(--ink); border: 1px solid rgba(255, 255, 255, 0.28); }
.btn.ghost:hover { background: rgba(255, 255, 255, 0.06); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.3; cursor: default; transform: none; }
[hidden] { display: none !important; }

/* PSL scan popup. */
.psl {
  width: min(960px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  margin: auto;
  padding: 0;
  border: 1px solid var(--line);
  background: #0a0a0a;
  color: var(--ink);
  overflow: auto;
}
.psl::backdrop { background: rgba(0, 0, 0, 0.82); }
.psl[open] { animation: pop 0.22s cubic-bezier(0.2, 0.9, 0.3, 1); }
@keyframes pop { from { opacity: 0; transform: scale(0.96); } }
.psl-body {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 28px;
  padding: 20px;
}

.cam {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  background: #000;
}
.cam video, .cam img, .cam canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.cam video, .cam img { visibility: hidden; }
.cam.cam-on video, .cam.photo-on img { visibility: visible; }
/* The camera shows like a mirror; a photo shows as it is. */
.cam.mirror video, .cam.mirror canvas { transform: scaleX(-1); }
.scan-start {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.scan-start .btn { width: 220px; justify-content: center; cursor: pointer; }
.cam canvas { pointer-events: none; }
.scanline {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 2px;
  background: var(--ink);
  box-shadow: 0 0 18px 2px rgba(255, 255, 255, 0.5);
  opacity: 0;
}
.psl.scanning .scanline { opacity: 0.85; animation: sweep 1.6s cubic-bezier(0.45, 0, 0.55, 1) infinite alternate; }
@keyframes sweep { to { transform: translateY(calc(var(--cam-h, 400px) - 2px)); } }
.cam-msg {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.75);
  font: 500 12px/1 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}
.cam-msg:empty { display: none; }

.readout {
  display: flex;
  flex-direction: column;
  padding: 8px 4px 4px 0;
}
.eyebrow {
  font: 500 12px/1 var(--mono);
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--dim);
}
.progress {
  margin-top: 14px;
  height: 2px;
  background: var(--line);
}
.progress span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--ink);
}
.metrics {
  list-style: none;
  padding: 0;
  margin-top: 8px;
}
.metrics li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 13px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 15px;
}
.metrics .k { color: var(--dim); }
.metrics .v { font: 500 15px/1 var(--mono); font-variant-numeric: tabular-nums; }
.metrics .v.wait { color: rgba(255, 255, 255, 0.24); }

.score { margin-top: 22px; }
.score.wait .score-num, .score.wait .tier { color: rgba(255, 255, 255, 0.24); }
.score-num {
  font: 400 96px/0.9 var(--display);
  font-variant-numeric: tabular-nums;
}
.score-of {
  margin-left: 6px;
  font: 400 32px/1 var(--display);
  color: var(--dim);
}
.tier {
  margin-top: 8px;
  font: 500 13px/1 var(--mono);
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

.psl-actions {
  margin-top: auto;
  padding-top: 24px;
  display: flex;
  gap: 8px;
}
.fine {
  margin-top: 14px;
  font-size: 12px;
  color: var(--dim);
}

/* Phone: title on top, clips in two columns below. */
@media (max-width: 720px) {
  body { overflow: auto; }
  .wall {
    height: auto;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: none;
  }
  .title {
    grid-column: 1 / -1;
    grid-row: 1;
    padding: 56px 16px 40px;
  }
  .name { font-size: 30vw; }
  .bar { flex-direction: column; height: auto; }
  .ca, .scan-btn { flex: none; height: 52px; }
  .tile { aspect-ratio: 1; }
  .psl-body { grid-template-columns: 1fr; gap: 16px; padding: 12px 12px 16px; }
  .readout { padding: 0 4px; }
  .score-num { font-size: 80px; }
}

@media (prefers-reduced-motion: reduce) {
  .tile .static { animation: none; }
  .psl.scanning .scanline { animation: none; opacity: 0; }
}
