/* 8it.co brand kit, ported for play.8it.co — the login gate (index.html) and
   the admin console (admin.html) share this one sheet.

   It is a deliberate COPY of the marketing site's styles.css, not a reference
   to it: play.8it.co must never fetch anything from 8it.co at runtime (one
   more origin to keep alive, and a login page that breaks when the marketing
   site does). When the brand moves there, port the diff by hand.

   Palette matches the game: blue grid, cyan airframe, yellow HUD, black sky. */

:root {
  --bg: #04060f;
  --panel: #060a1a;
  --ink: #c2e6f2;
  --cyan: #3fe0ff;
  --blue: #3550e8;
  --dim: #7d90f2;
  --yellow: #ffd400;
  --line: rgba(53, 80, 232, 0.38);
  --danger: #ff6b6b;
  --mono: ui-monospace, "SF Mono", Menlo, "Cascadia Mono", "JetBrains Mono",
          Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ---- CRT overlay: scanlines + vignette, purely decorative ---- */
.crt {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  background:
    repeating-linear-gradient(0deg,
      rgba(0, 0, 0, 0.16) 0 1px,
      transparent 1px 3px);
}
.crt::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center,
    transparent 58%, rgba(0, 0, 0, 0.42) 100%);
}

/* ---- header ---- */
.top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 1.4rem 1.25rem 0;
}
.brand {
  color: var(--cyan);
  text-decoration: none;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.06em;
  text-shadow: 0 0 12px rgba(63, 224, 255, 0.4);
}
.cursor { animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.top nav a, main a, .drill a {
  color: var(--yellow);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}
.top nav a { font-size: 0.8rem; letter-spacing: 0.12em; }
.top nav a:hover, main a:hover { color: #ffe566; }

/* ---- type ---- */
.kicker {
  color: var(--dim);
  font-size: 0.8rem;
  letter-spacing: 0.35em;
}

.logo {
  font-size: clamp(2.6rem, 9vw, 5rem);
  line-height: 1.02;
  letter-spacing: 0.06em;
  color: var(--cyan);
  font-weight: 700;
  text-shadow:
    0 0 18px rgba(63, 224, 255, 0.45),
    0 0 60px rgba(63, 224, 255, 0.2);
  margin: 0.4rem 0 0.5rem;
}

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

/* The terminal block: any read-out the machine is talking through. On the
   login page #status IS one of these, so the `>` has to come from CSS —
   main.ts owns its textContent and knows nothing about the brand. */
.status {
  padding: 0.85rem 1.1rem;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--cyan);
  font-size: 0.85rem;
  line-height: 1.8;
  letter-spacing: 0.03em;
  box-shadow: inset 0 0 40px rgba(63, 224, 255, 0.05);
}
.status::before { content: "> "; color: var(--dim); }

/* ---- controls ---- */
button,
a.button {
  display: inline-block;
  font: inherit;
  font-size: 0.85rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  padding: 0.55rem 1.6rem;
  border: 1px solid var(--yellow);
  border-radius: 0;
  background: transparent;
  color: var(--yellow);
  transition: background 0.12s linear, color 0.12s linear;
}
button:hover,
a.button:hover { background: var(--yellow); color: var(--bg); }

button.ghost {
  border-color: var(--line);
  color: var(--cyan);
}
button.ghost:hover { background: rgba(63, 224, 255, 0.12); color: var(--cyan); }

button.danger {
  border-color: rgba(255, 107, 107, 0.5);
  color: var(--danger);
}
button.danger:hover { background: rgba(255, 107, 107, 0.15); color: var(--danger); }

input[type=email], input[type=text], input[type=password] {
  font: inherit;
  font-size: 0.85rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--panel);
  color: var(--ink);
  min-width: 18rem;
}
input[type=email]:focus, input[type=text]:focus, input[type=password]:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 0 1px rgba(63, 224, 255, 0.25);
}
::placeholder { color: rgba(125, 144, 242, 0.6); }

/* ---- selection + motion ---- */
::selection { background: rgba(63, 224, 255, 0.35); color: #eafbff; }

@media (prefers-reduced-motion: reduce) {
  .cursor { animation: none; }
  button, a.button { transition: none; }
}

/* =====================================================================
   LOGIN GATE (index.html)
   ===================================================================== */
.gate-main {
  max-width: 44rem;
  margin: 0 auto;
  padding: clamp(2rem, 12vh, 6rem) 1.25rem 3rem;
}
.hero-sub {
  color: var(--yellow);
  font-size: 0.8rem;
  letter-spacing: 0.35em;
  margin-bottom: 2rem;
}
/* The hidden attribute must always win: admin.html hides #app until the PKCE
   exchange succeeds, and the explicit display below would otherwise resurrect
   it for anonymous visitors (bit the owner 2026-08-04 — the invite form and
   empty roster rendered under the sign-in prompt). */
[hidden] { display: none !important; }

/* #app is main.ts's mount point — it appends the sign-in <a class="button">
   here, so this rule has to work with 1 child (status) and 2 (status+button). */
#app {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1.25rem;
  border-top: 1px solid var(--line);
  padding-top: 1.8rem;
}
#status { align-self: stretch; }

/* The four #app forms (main.ts builds each via createElement, appended into
   #app the same way the old Hosted-UI-redirect button used to be):
   #signin-form (email+password), #newpw-form (the first-sign-in forced
   password change), #forgot-form (request a reset code), #forgot-confirm-form
   (code + new password). */
#signin-form, #newpw-form, #forgot-form, #forgot-confirm-form {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1rem;
  width: 100%;
  max-width: 22rem;
}
#signin-form .field, #newpw-form .field, #forgot-form .field, #forgot-confirm-form .field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  width: 100%;
}
#signin-form .field label, #newpw-form .field label,
#forgot-form .field label, #forgot-confirm-form .field label {
  color: var(--dim);
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
#signin-form input, #newpw-form input, #forgot-form input, #forgot-confirm-form input {
  width: 100%;
  min-width: 0;
}
.form-error {
  color: var(--danger);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}
.forgot-link {
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-decoration-thickness: 1px;
}

/* Admin-set sign-in notice + tester build stamp (main.ts fills both from
   GET /auth/motd; hidden when there's nothing to say). */
.notice {
  max-width: 34rem;
  margin: 0 0 1.4rem;
  padding: 0.8rem 1rem;
  border: 1px solid var(--line);
  border-left: 3px solid var(--yellow);
  background: var(--panel);
  color: var(--yellow);
  font-size: 0.85rem;
  line-height: 1.55;
  white-space: pre-line; /* the admin's line breaks survive; markup never renders */
}
.build-info {
  color: var(--dim);
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-top: 1.2rem;
}
.build-info .sha { color: var(--cyan); }

.disclosure {
  color: var(--dim);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  line-height: 1.6;
  margin-top: 1.6rem;
  max-width: 52ch;
}

footer {
  border-top: 1px solid var(--line);
  margin-top: 2rem;
  padding: 1.4rem 1.25rem 2rem;
  text-align: center;
  color: var(--dim);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
}

/* =====================================================================
   ADMIN CONSOLE (admin.html)
   ===================================================================== */
.admin-main { padding: 1.4rem 1.25rem 3rem; }

.admin-title {
  color: var(--cyan);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.28em;
  margin-bottom: 1.2rem;
}
.admin-main > #status { max-width: 40rem; }
/* admin.ts injects a bare <button id="signin"> right after #status. */
#signin { margin-top: 1rem; }

form#new {
  margin: 1.2rem 0 1.6rem;
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  align-items: center;
}
form#new .muted { flex: 1 1 18rem; }

/* Invite-codes section + roster filter bar (admin.ts). */
.codes-title {
  color: var(--cyan);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.28em;
  margin: 2.2rem 0 0.4rem;
}
form#new-code {
  margin: 0.8rem 0 1.2rem;
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  align-items: flex-end; /* labels sit above inputs; button lines up with the inputs */
}
form#new-code .muted { flex: 1 1 18rem; align-self: center; }
form#new-code .field { display: flex; flex-direction: column; gap: 0.3rem; }
form#new-code .field > span {
  color: var(--dim);
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
form#new-code input[type=number], form#new-code input[type=date] {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--ink);
  font: inherit;
  padding: 0.5rem 0.7rem;
}
form#motd { margin: 0.8rem 0 1.2rem; display: flex; flex-direction: column; gap: 0.6rem; max-width: 44rem; }
form#motd textarea {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--ink);
  font: inherit;
  padding: 0.5rem 0.7rem;
  resize: vertical;
}
.motd-row { display: flex; gap: 0.8rem; align-items: center; }
.roster-controls { display: flex; gap: 0.6rem; flex-wrap: wrap; margin: 0 0 0.8rem; }
.roster-controls input[type=search], .roster-controls select {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--ink);
  font: inherit;
  padding: 0.45rem 0.7rem;
}
thead th[data-sort] { cursor: pointer; }
thead th[data-sort]:hover { color: var(--yellow); }
thead th.sorted::after { content: " ▲"; color: var(--yellow); }
thead th.sorted.desc::after { content: " ▼"; }
td .src { color: var(--cyan); text-decoration: none; }
td .src:hover { color: var(--yellow); }
.optin-badge {
  color: var(--yellow);
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.wrap { overflow-x: auto; border: 1px solid var(--line); background: var(--panel); }

table { border-collapse: collapse; width: 100%; font-size: 0.85rem; }
th, td { text-align: left; padding: 0.6rem 0.7rem; vertical-align: top; }
thead th {
  color: var(--cyan);
  font-weight: 700;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid rgba(53, 80, 232, 0.18); }
tbody tr.user { cursor: pointer; }
tbody tr.user:hover { background: rgba(63, 224, 255, 0.045); }
tbody tr.user.open { background: rgba(63, 224, 255, 0.07); }
tr.disabled td { opacity: 0.45; }
td.num { color: var(--cyan); white-space: nowrap; }
td .stamp { white-space: nowrap; }

.tag {
  padding: 0.12rem 0.6rem;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--dim);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin: 0.1rem 0.2rem 0.1rem 0;
}
.tag:hover { background: rgba(63, 224, 255, 0.12); color: var(--cyan); }
.tag.on { border-color: var(--cyan); color: var(--cyan); box-shadow: 0 0 10px rgba(63, 224, 255, 0.18); }

.actions { white-space: nowrap; }
.actions button {
  margin: 0.1rem 0.2rem 0.1rem 0;
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  padding: 0.28rem 0.7rem;
}

.state-new { color: var(--yellow); }
.state-off { color: var(--danger); }

/* ---- session drill-down ---- */
tr.drill > td { background: rgba(4, 6, 15, 0.75); border-top: 1px solid var(--line); padding: 1rem 1.1rem 1.2rem; }
.drill-head {
  color: var(--dim);
  font-size: 0.68rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  margin-bottom: 0.8rem;
}
/* 50 sessions would otherwise push the rest of the roster off the screen. */
.drill-list { max-height: 26rem; overflow-y: auto; padding-right: 0.4rem; }
.ses {
  border-left: 2px solid var(--line);
  padding: 0.5rem 0 0.7rem 0.9rem;
  margin-bottom: 0.9rem;
}
.ses:last-child { margin-bottom: 0; }
.ses-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.7rem;
  color: var(--cyan);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
}
.ses-dur { color: var(--yellow); }
.ses-sha { color: var(--dim); font-size: 0.72rem; }
.ses-meta { color: var(--dim); font-size: 0.72rem; letter-spacing: 0.02em; margin-top: 0.15rem; }

.chip {
  padding: 0.05rem 0.5rem;
  border: 1px solid var(--line);
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--dim);
}
.chip-dev { border-color: rgba(255, 212, 0, 0.5); color: var(--yellow); }
.chip-tester { border-color: rgba(63, 224, 255, 0.5); color: var(--cyan); }

.counters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.4rem;
  margin-top: 0.6rem;
}
.ctr { display: flex; align-items: baseline; gap: 0.4rem; }
.ctr-n { color: var(--cyan); font-size: 0.95rem; }
.ctr-n.zero { color: var(--dim); opacity: 0.5; }
.ctr-l { color: var(--dim); font-size: 0.62rem; letter-spacing: 0.16em; }

/* ---- telemetry browser (telemetry.html) ---- */
.tele-filters {
  margin: 0.8rem 0 1.2rem;
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  align-items: flex-end;
}
.tele-filters .muted { align-self: center; }
.tele-filters .field { display: flex; flex-direction: column; gap: 0.3rem; }
.tele-filters .field > span {
  color: var(--dim);
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.tele-filters input[type=date], .tele-filters select {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--ink);
  font: inherit;
  padding: 0.45rem 0.7rem;
}
#more { margin-top: 0.8rem; }
/* Six counters in one cell — inline version of the drill-down's .ctr blocks. */
.tele-counters { white-space: nowrap; }
.tele-counters .ctr { display: inline-flex; margin-right: 0.9rem; }

/* Event timeline inside a session drill. */
.ev-chips { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-bottom: 0.7rem; }
.ev-list {
  max-height: 26rem;
  overflow-y: auto;
  font-family: var(--mono);
  font-size: 0.75rem;
}
.ev-row {
  display: flex;
  gap: 0.8rem;
  padding: 0.14rem 0;
  border-bottom: 1px solid rgba(53, 80, 232, 0.12);
}
.ev-t { color: var(--dim); flex: 0 0 5.5rem; text-align: right; }
.ev-name { color: var(--cyan); flex: 0 0 9rem; }
.ev-data {
  color: var(--ink);
  opacity: 0.75;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ev-more { margin-top: 0.7rem; }

@media (max-width: 620px) {
  .admin-main { padding: 1rem 0.75rem 2rem; }
  input[type=email], input[type=text] { min-width: 12rem; }
}
