:root {
  --font: 'Chakra Petch', 'Segoe UI', system-ui, sans-serif;
  --panel: rgba(30, 32, 38, 0.82);
  --panel-solid: #24262c;
  --panel-2: #2c2f36;
  --edge-dark: #0b0c0e;
  --edge-light: #41454d;
  --text: #e8e3d7;
  --muted: #a19b8d;
  --amber: #f2c14e;
  --orange: #e8892c;
  --good: #79d36d;
  --bad: #e5533d;
  --sleep: #6fb6e0;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(ellipse at 50% 0%, #1c1e23 0%, #101114 65%);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
}
body { min-height: 100dvh; }

.hidden { display: none !important; }
.muted { color: var(--muted); }

/* The running factory behind everything (scene.js), faded in once it draws. */
.scene {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  opacity: 0;
  transition: opacity 1.2s ease;
}
.scene.on { opacity: 1; }
.shade {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 70% 60% at 50% 42%, rgba(16, 17, 20, 0.55) 0%, rgba(16, 17, 20, 0.15) 60%, rgba(16, 17, 20, 0) 100%),
    linear-gradient(180deg, rgba(16, 17, 20, 0.55) 0%, rgba(16, 17, 20, 0) 22%, rgba(16, 17, 20, 0) 70%, rgba(16, 17, 20, 0.85) 100%);
}

.lobby {
  position: relative;
  max-width: 560px;
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(40px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
}

.hero { text-align: center; text-shadow: 0 2px 12px rgba(0, 0, 0, 0.8); }
.logo { margin: 0; font-size: clamp(48px, 14vw, 84px); letter-spacing: 0.04em; line-height: 1; }
.logo .meta { color: var(--amber); text-shadow: 0 0 24px rgba(242, 193, 78, 0.45), 0 2px 10px rgba(0, 0, 0, 0.8); }
.logo .fab { color: var(--text); }
.tagline { margin: 8px 0 0; color: var(--amber); letter-spacing: 0.3em; text-transform: uppercase; font-size: 12px; }
.pitch { margin: 14px auto 0; max-width: 30em; color: var(--text); line-height: 1.5; }

.panel {
  background: var(--panel);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid var(--edge-dark);
  box-shadow: inset 0 1px 0 var(--edge-light), 0 12px 40px rgba(0, 0, 0, 0.45);
  border-radius: 8px;
  padding: 18px;
}
.center { text-align: center; }
.center p { margin: 0 0 14px; }

.btn {
  display: inline-block;
  font: inherit;
  font-weight: 600;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--edge-dark);
  box-shadow: inset 0 1px 0 var(--edge-light);
  border-radius: 4px;
  padding: 10px 16px;
  min-height: 44px;
  cursor: pointer;
  text-decoration: none;
}
@media (hover: hover) { .btn:hover { filter: brightness(1.15); } }
.btn:disabled { opacity: 0.55; cursor: default; filter: none; }
.btn.primary { background: linear-gradient(#f0a641, var(--orange)); color: #1a1205; box-shadow: inset 0 1px 0 #ffd38a, 0 0 18px rgba(232, 137, 44, 0.35); }
.btn.big { padding: 13px 22px; font-size: 16px; }
.btn.small { padding: 5px 10px; font-size: 13px; min-height: 32px; }

.who { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.tag { margin-left: 8px; padding: 1px 6px; border-radius: 3px; background: #3a3220; color: var(--amber); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; }

.worlds { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.world { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 6px; background: rgba(16, 17, 20, 0.55); border: 1px solid var(--edge-dark); }
.world .info { flex: 1; min-width: 0; }
.world .name { font-size: 17px; font-weight: 700; overflow-wrap: anywhere; }
.world .state { margin-top: 4px; font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.worlds > .muted { padding: 12px 14px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.awake { background: var(--good); box-shadow: 0 0 6px var(--good); }
.dot.asleep { background: var(--sleep); }
.dot.starting { background: var(--amber); animation: pulse 1s ease-in-out infinite; }
.dot.unknown { background: var(--bad); }
@keyframes pulse { 50% { opacity: 0.35; } }

.error { margin: 0; padding: 10px 14px; border-radius: 4px; background: #3a1b17; border: 1px solid #6b2a21; color: #ffb4a6; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.row { display: flex; gap: 8px; align-items: center; }
.center-row { justify-content: center; flex-wrap: wrap; }
.world { flex-wrap: wrap; }
.world .meta-line { margin-top: 2px; font-size: 12px; color: var(--muted); }
.world .actions { display: flex; gap: 8px; }
.invite-box { flex-basis: 100%; padding-top: 10px; border-top: 1px solid var(--edge-light); }
.invite-box p { margin: 0 0 8px; font-size: 13px; color: var(--muted); }
.invite-box input { flex: 1; min-width: 0; }
input {
  font: inherit;
  color: var(--text);
  background: rgba(16, 17, 20, 0.7);
  border: 1px solid var(--edge-light);
  border-radius: 4px;
  padding: 9px 10px;
  min-height: 44px;
}
.create { display: flex; gap: 8px; margin-top: 12px; }
.create input { flex: 1; min-width: 0; }
.invite { border-color: #6b5420; box-shadow: inset 0 1px 0 #8a6d2a, 0 0 24px rgba(242, 193, 78, 0.2); }
.ranking h2 { margin: 0 0 10px; font-size: 14px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--amber); }
.ranking ol { margin: 0; padding-left: 26px; display: flex; flex-direction: column; gap: 6px; }
.ranking li { display: grid; grid-template-columns: 1fr auto; column-gap: 10px; }
.ranking li::marker { color: var(--amber); font-weight: 700; }
.ranking .r-name { font-weight: 700; overflow-wrap: anywhere; }
.ranking .r-num { color: var(--amber); font-variant-numeric: tabular-nums; }
.ranking .r-extra { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }

/* What the factory behind has made since the page opened. */
.ticker {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  text-align: center;
}
.ticker > div { padding: 8px 4px; border-radius: 6px; background: rgba(16, 17, 20, 0.6); border: 1px solid rgba(65, 69, 77, 0.6); }
.ticker dt { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.ticker dd { margin: 4px 0 0; font-size: 18px; font-weight: 700; color: var(--amber); font-variant-numeric: tabular-nums; }

footer { text-align: center; font-size: 12px; text-shadow: 0 1px 6px rgba(0, 0, 0, 0.9); }

@media (max-width: 520px) {
  .ticker { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 420px) {
  .world { flex-direction: column; align-items: stretch; }
  .world .actions .btn { flex: 1; text-align: center; }
  .create { flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
  .scene { transition: none; }
  .dot.starting { animation: none; }
}
