:root {
  --bg: #0c0e14;
  --bg2: #141824;
  --card: #181d2b;
  --card-hi: #1d2438;
  --line: #2a3142;
  --fg: #e7ecf5;
  --muted: #9aa4ba;
  --accent: #6ea8fe;
  --ok: #57d9a3;
  --pending: #e0b341;
  --broken: #f08a8a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}

a { color: var(--accent); }

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: #00000040;
  padding: 0.05em 0.35em;
  border-radius: 4px;
  font-size: 0.9em;
}

/* ---------- landing ---------- */
.hero {
  max-width: 880px;
  margin: 0 auto;
  padding: 3.2rem 1.25rem 1.5rem;
}
.hero h1 {
  font-size: clamp(2rem, 6vw, 3rem);
  margin: 0 0 0.6rem;
  background: linear-gradient(90deg, #8ab4ff, #b58cff 60%, #57d9a3);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero .tag { font-size: 1.12rem; color: #cdd5e6; margin: 0 0 0.8rem; }
.hero .note { color: var(--muted); margin: 0; font-size: 0.97rem; }

.grid {
  max-width: 980px;
  margin: 1rem auto 2rem;
  padding: 0 1.25rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.05rem 1.1rem 1.15rem;
  text-decoration: none;
  color: var(--fg);
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}
.card:hover { transform: translateY(-3px); border-color: var(--accent); background: var(--card-hi); }
.card--highlight { border-color: #36507f; box-shadow: 0 0 0 1px #2f3b58 inset; }

.card__top { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.card__name { font-size: 1.18rem; font-weight: 650; }
.card__engine { color: var(--accent); font-size: 0.92rem; font-weight: 500; }
.card__era { color: var(--muted); font-weight: 400; }
.card__blurb { color: var(--muted); font-size: 0.92rem; margin: 0.1rem 0 0.3rem; flex: 1; }
.card__foot { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.card__go { color: var(--fg); font-weight: 600; font-size: 0.92rem; }
.card__dl {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 600;
  background: #00000038;
  border: 1px solid var(--line);
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  white-space: nowrap;
}

.badge {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  white-space: nowrap;
}
.badge--ok { background: #143a2c; color: var(--ok); }
.badge--pending { background: #3a3216; color: var(--pending); }
.badge--broken { background: #3a1c1c; color: var(--broken); }

.foot {
  max-width: 980px;
  margin: 0 auto;
  padding: 1rem 1.25rem 3rem;
  color: var(--muted);
  font-size: 0.86rem;
  border-top: 1px solid var(--line);
}
.foot p { margin: 0.3rem 0; }

/* ---------- runner ---------- */
body.runner {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}
.bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.85rem;
  background: var(--bg2);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.bar__back {
  font-size: 1.3rem;
  text-decoration: none;
  padding: 0 0.4rem;
  border-radius: 8px;
}
.bar__back:hover { background: #ffffff14; }
.bar__title { display: flex; flex-direction: column; line-height: 1.15; }
.bar__title #title { font-weight: 650; }
.bar__engine { color: var(--accent); font-size: 0.8rem; }
.bar__dl { color: var(--muted); font-size: 0.74rem; cursor: help; }
.bar__status {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  margin-left: auto;
  text-align: right;
}
#status { font-weight: 600; }
#status[data-kind="busy"] { color: var(--pending); }
#status[data-kind="ok"] { color: var(--ok); }
#status[data-kind="error"] { color: var(--broken); }
.bar__net { font-size: 0.78rem; color: var(--muted); }
.bar__net[data-kind="ok"] { color: var(--ok); }

.bar__controls { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; }
.bar__controls input {
  background: #0c0f17;
  border: 1px solid var(--line);
  color: var(--fg);
  border-radius: 8px;
  padding: 0.35rem 0.55rem;
  width: 12rem;
  font-size: 0.85rem;
}
.bar__controls button {
  background: #232b3e;
  border: 1px solid var(--line);
  color: var(--fg);
  border-radius: 8px;
  padding: 0.35rem 0.6rem;
  font-size: 0.82rem;
  cursor: pointer;
}
.bar__controls button:hover { background: #2d374e; border-color: var(--accent); }
.bar__relaylabel { font-size: 0.78rem; color: var(--muted); }
.bar__relay {
  background: #0c0f17;
  border: 1px solid var(--line);
  color: var(--fg);
  border-radius: 8px;
  padding: 0.33rem 0.4rem;
  font-size: 0.8rem;
  max-width: 15rem;
  cursor: pointer;
}
.bar__relay:hover { border-color: var(--accent); }

/* Thin download progress bar shown while the OS image / state streams in. */
.progress {
  position: relative;
  height: 1.5rem;
  background: #0c0f17;
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}
.progress__bar {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 0%;
  background: linear-gradient(90deg, #2c4a86, #3b6fd6);
  transition: width 0.2s ease;
}
.progress__bar.is-indeterminate {
  width: 35% !important;
  animation: progress-slide 1.1s linear infinite;
}
@keyframes progress-slide {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(340%); }
}
.progress__label {
  position: relative;
  display: block;
  padding: 0 0.8rem;
  font-size: 0.78rem;
  line-height: 1.5rem;
  color: #dbe6fb;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 2px #000a;
}

.hint {
  background: #1b2740;
  color: #cdd9f0;
  border-bottom: 1px solid var(--line);
  padding: 0.45rem 0.95rem;
  font-size: 0.88rem;
  cursor: pointer;
}
.hint:hover { background: #21304e; }

.stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  background:
    radial-gradient(1200px 600px at 50% -10%, #1a2236 0%, var(--bg) 60%);
  padding: 0.5rem;
}
#screen_container {
  position: relative;
  background: #000;
  color: #d8d8d8;
  box-shadow: 0 8px 40px #00000080;
  /* Touch: let drags move the guest cursor instead of scrolling/zooming the
     page, and don't let a tap select text. */
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
#screen_container canvas { display: block; }

/* On-screen keyboard target: present + focusable (so focusing raises the mobile
   soft keyboard) but visually hidden. Not display:none / visibility:hidden, or
   focus()/the keyboard won't work on iOS. */
.phone_keyboard {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: 0;
  border: 0;
  opacity: 0;
  background: transparent;
  color: transparent;
  z-index: -1;
}
#kbdtoggle.is-active { background: var(--accent); color: #0c0e14; border-color: var(--accent); }

/* Touch / small-screen layout: stack the toolbar, give controls big tap targets,
   and let the type-into-guest field grow to fill the row. */
@media (max-width: 760px) {
  .bar { gap: 0.5rem; padding: 0.45rem 0.6rem; }
  .bar__status { margin-left: auto; }
  .bar__controls { width: 100%; gap: 0.45rem; }
  .bar__controls input#sendtext { flex: 1 1 8rem; width: auto; min-width: 0; }
  .bar__controls button {
    min-height: 2.4rem;
    padding: 0.4rem 0.7rem;
    font-size: 0.9rem;
  }
  .bar__relay { flex: 1 1 7rem; min-height: 2.4rem; }
}
@media (pointer: coarse) {
  /* Generous tap targets on touch devices regardless of width. */
  .bar__controls button, .bar__back { min-height: 2.4rem; }
}
