:root {
  /* The machine: a CRT that is off, then the amber phosphor it glows in. */
  --void: #06080f;
  --panel: #0d1220;
  --panel-lift: #131a2c;
  --rule: #1e2a44;
  --rule-bright: #2c3d5f;

  --phosphor: #ffb000;
  --phosphor-dim: #7a5410;
  --phosphor-wash: rgba(255, 176, 0, 0.08);

  /* People are cyan, the machine is amber. Presence never competes with UI. */
  --human: #3fd0d4;
  --human-dim: #1f6a6c;

  --text: #b9c6de;
  --muted: #5d6f92;
  --live: #57d98a;
  --alarm: #ff6b6b;

  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "IBM Plex Mono", Menlo, Consolas, monospace;

  --shelf-gap: 1.25rem;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--void);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* A very faint scanline field over the whole page. It is the one piece of
   decoration, and it is the reason the thing reads as a monitor. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.016) 0px,
    rgba(255, 255, 255, 0.016) 1px,
    transparent 1px,
    transparent 3px
  );
}

a { color: var(--phosphor); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--phosphor);
  outline-offset: 2px;
}

.wrap {
  max-width: 74rem;
  margin: 0 auto;
  padding: 1.75rem 1.5rem 7rem;
}

/* ------------------------------------------------------------------- bar */

.bar {
  display: flex;
  align-items: center;
  gap: 1ch;
  padding-bottom: 1rem;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--rule);
  flex-wrap: wrap;
}

.mark {
  font-size: 1rem;
  letter-spacing: -0.02em;
  color: var(--muted);
}

.mark b {
  color: var(--phosphor);
  font-weight: 600;
}

.bar .spacer { flex: 1; }

.bar nav { display: flex; gap: 1.75ch; align-items: center; }

.whoami { color: var(--human); }

.cursor {
  display: inline-block;
  width: 0.55ch;
  height: 0.95em;
  background: var(--phosphor);
  vertical-align: text-bottom;
  animation: blink 1.15s steps(1) infinite;
}

@keyframes blink { 50% { opacity: 0; } }

/* ----------------------------------------------------------------- shelf */

.shelf {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
  gap: var(--shelf-gap);
}

.game {
  display: block;
  color: inherit;
  border: 1px solid var(--rule);
  background: var(--panel);
  transition: border-color 120ms linear;
}

.game:hover,
.game:focus-visible {
  border-color: var(--phosphor-dim);
  text-decoration: none;
}

.game .cover {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;   /* the shape of the screen these ran on */
  object-fit: cover;
  background: var(--void);
  border-bottom: 1px solid var(--rule);
}

.game .meta { padding: 0.7rem 0.85rem 0.8rem; }

.game .name {
  color: var(--text);
  font-weight: 500;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.game .state {
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.8ch;
  flex-wrap: wrap;
}

.game .state .kept { color: var(--live); }

.badge {
  border: 1px solid var(--human-dim);
  color: var(--human);
  padding: 0 0.5ch;
  font-size: 0.78rem;
}

/* The add tile sits in the shelf rather than above it, so the grid stays the
   hero and adding a game is part of the same gesture as picking one. */
.game.add {
  border-style: dashed;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 12rem;
  color: var(--muted);
  text-align: center;
  padding: 1rem;
}

.game.add:hover { color: var(--phosphor); border-color: var(--phosphor-dim); }

/* --------------------------------------------------------------- panels */

.panel {
  background: var(--panel);
  border: 1px solid var(--rule);
  padding: 1.4rem 1.5rem;
  margin-bottom: 1.5rem;
}

.panel h2 {
  margin: 0 0 0.3rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--phosphor);
  letter-spacing: -0.01em;
}

.panel .hint { margin: 0 0 1rem; color: var(--muted); max-width: 62ch; }

.row { display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; }
.row > * { flex: 1 1 12rem; }
.row > .shrink { flex: 0 0 auto; }

label {
  display: block;
  color: var(--muted);
  margin: 1.1rem 0 0.35rem;
}

input[type="text"], input[type="password"], input[type="file"], select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--void);
  border: 1px solid var(--rule);
  padding: 0.45rem 0.65rem;
  width: 100%;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--phosphor-dim);
  outline: none;
}

button, .btn {
  font: inherit;
  color: var(--phosphor);
  background: transparent;
  border: 1px solid var(--phosphor-dim);
  padding: 0.3rem 0.95rem;
  cursor: pointer;
  transition: background-color 120ms linear;
}

button:hover, .btn:hover { background: var(--phosphor-wash); text-decoration: none; }
button:disabled { opacity: 0.4; cursor: not-allowed; }
button.quiet { color: var(--muted); border-color: var(--rule); }
button.quiet:hover { color: var(--text); }
button.danger { color: var(--alarm); border-color: #4a2230; }

.notice {
  border-left: 2px solid var(--phosphor-dim);
  padding: 0.5rem 0 0.5rem 1rem;
  margin: 1rem 0;
  color: var(--muted);
}

.notice.error { border-color: var(--alarm); color: var(--alarm); }
.notice.ok { border-color: var(--live); color: var(--live); }

.empty {
  color: var(--muted);
  border: 1px dashed var(--rule);
  padding: 3rem 1.5rem;
  text-align: center;
}

/* ------------------------------------------------- cover picker (import) */

.covers {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(7rem, 1fr));
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.covers label {
  margin: 0;
  cursor: pointer;
  border: 1px solid var(--rule);
  padding: 0;
  position: relative;
}

.covers input { position: absolute; opacity: 0; }
.covers img, .covers .swatch {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--void);
}

.covers .swatch {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
  padding: 0.5rem;
}

.covers label:has(input:checked) { border-color: var(--phosphor); }

/* ---------------------------------------------------------------- player */

.stage {
  background: #000;
  border: 1px solid var(--rule);
  width: 100%;
  aspect-ratio: 4 / 3;
  max-height: 74vh;
  overflow: hidden;
}

.statusbar {
  display: flex;
  gap: 1.5ch;
  align-items: center;
  flex-wrap: wrap;
  color: var(--muted);
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 1.25rem;
}

.statusbar .spacer { flex: 1; }

.dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--muted);
  margin-right: 0.7ch;
}

.dot.live { background: var(--live); }
.dot.warn { background: var(--phosphor); }

.log {
  margin: 1.25rem 0 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
  max-height: 14rem;
  overflow-y: auto;
  font-size: 0.88rem;
}

.log li {
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--rule);
  display: flex;
  gap: 1.5ch;
  align-items: baseline;
}

.log time { color: var(--phosphor-dim); flex: 0 0 auto; }
.log .grow { flex: 1; }
.log .warn { color: var(--phosphor); }
.log .saved { color: var(--live); }

.listing { width: 100%; border-collapse: collapse; }
.listing td {
  padding: 0.55rem 1rem 0.55rem 0;
  border-bottom: 1px solid var(--rule);
  vertical-align: baseline;
}
.listing .num { color: var(--muted); white-space: nowrap; }
.listing .actions { text-align: right; white-space: nowrap; }

/* ------------------------------------------------------------------ dock */

.dock {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  width: 20rem;
  max-width: calc(100vw - 2.5rem);
  background: var(--panel);
  border: 1px solid var(--rule-bright);
  z-index: 50;
  display: flex;
  flex-direction: column;
}

.dock-head {
  display: flex;
  align-items: center;
  gap: 0.8ch;
  padding: 0.55rem 0.8rem;
  cursor: pointer;
  border-bottom: 1px solid transparent;
  background: none;
  color: inherit;
  width: 100%;
  text-align: left;
  font: inherit;
}

.dock.open .dock-head { border-bottom-color: var(--rule); }
.dock-head:hover { background: var(--panel-lift); }

.dock-head .who { flex: 1; color: var(--text); }
.dock-head .count { color: var(--muted); }

/* The only attention-seeking motion on the page, and only when someone has
   actually said something. */
.dock.unread { border-color: var(--human); }
.dock.unread .dock-head .who { color: var(--human); }
.dock.unread .pip { animation: pulse 1.1s ease-in-out infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

.pip {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex: 0 0 auto;
}

.pip.on { background: var(--human); }

.dock-body { display: none; }
.dock.open .dock-body { display: block; }

.roster {
  list-style: none;
  margin: 0;
  padding: 0.5rem 0.8rem;
  border-bottom: 1px solid var(--rule);
  font-size: 0.88rem;
}

.roster li {
  display: flex;
  align-items: baseline;
  gap: 0.8ch;
  padding: 0.2rem 0;
}

.roster .name { color: var(--human); }
.roster .doing { color: var(--muted); flex: 1; overflow-wrap: anywhere; }
.roster .join {
  font-size: 0.82rem;
  padding: 0 0.6ch;
  flex: 0 0 auto;
}

.roster .nobody { color: var(--muted); }

.messages {
  list-style: none;
  margin: 0;
  padding: 0.6rem 0.8rem;
  height: 13rem;
  overflow-y: auto;
  font-size: 0.88rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.messages .from { color: var(--human); }
.messages .mine .from { color: var(--phosphor); }
.messages .sys { color: var(--muted); font-style: italic; }

.composer {
  display: flex;
  gap: 0;
  border-top: 1px solid var(--rule);
}

.composer input {
  border: none;
  background: var(--void);
  border-radius: 0;
}

.composer button {
  border: none;
  border-left: 1px solid var(--rule);
  flex: 0 0 auto;
}

@media (prefers-reduced-motion: reduce) {
  .cursor, .dock.unread .pip { animation: none; }
  * { transition: none !important; }
}

@media (max-width: 640px) {
  .wrap { padding: 1.25rem 1rem 6rem; }
  .shelf { grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); }
  .dock { left: 0.75rem; right: 0.75rem; bottom: 0.75rem; width: auto; }
  .messages { height: 10rem; }
}
