:root {
  --bg: #05061a;
  --bg-2: #0b0d2a;
  --panel: rgba(16, 19, 52, 0.78);
  --line: rgba(120, 140, 255, 0.18);
  --text: #e8ebff;
  --muted: #8f96c7;
  --cyan: #36f1ff;
  --pink: #ff5fd2;
  --violet: #9b5cff;
  --gold: #ffe066;
  --green: #5effa8;
  --red: #ff4d6d;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: radial-gradient(1200px 600px at 70% -10%, #1a1050 0%, transparent 60%), var(--bg);
  color: var(--text);
  font: 16px/1.55 Inter, system-ui, sans-serif;
  overflow-x: hidden;
}
a { color: var(--cyan); }
h1, h2, h3, .brand, .hud-title { font-family: Orbitron, Inter, sans-serif; letter-spacing: 0.02em; }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  max-width: 1280px; margin: 0 auto; padding: 18px 16px;
}
.brand { font-weight: 900; font-size: 22px; color: var(--text); text-decoration: none; display: flex; align-items: center; gap: 10px; }
.glyph { width: 14px; height: 22px; background: linear-gradient(180deg, var(--pink), var(--cyan)); clip-path: polygon(50% 0, 100% 35%, 50% 100%, 0 35%); box-shadow: 0 0 18px var(--cyan); }
.top nav { display: flex; gap: 18px; flex-wrap: wrap; }
.top nav a { color: var(--muted); text-decoration: none; font-size: 14px; }
.top nav a:hover { color: var(--text); }

main { max-width: 1280px; margin: 0 auto; padding: 0 16px; }

.hero { padding: 8px 0 20px; max-width: 760px; }
.hero h1 { font-size: clamp(28px, 5vw, 48px); line-height: 1.1; margin: 0 0 12px; }
.hero em { font-style: normal; background: linear-gradient(90deg, var(--cyan), var(--pink)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { color: var(--muted); margin: 0; font-size: 17px; }

.stage { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
@media (min-width: 1000px) { .stage { grid-template-columns: minmax(0, 1fr) 320px; } }
.stage > * { min-width: 0; }

.viewport { align-self: start; position: relative; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: #03040f; }
.world { width: 100%; height: clamp(360px, 64vh, 720px); }
.world canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.hud { position: absolute; left: 14px; top: 12px; pointer-events: none; }
.hud-title { font-weight: 700; font-size: 18px; text-shadow: 0 0 12px rgba(54, 241, 255, 0.6); }
.hud-row { display: flex; gap: 10px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
.counts { color: var(--muted); font-size: 13px; }
.pill { font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 99px; border: 1px solid currentColor; }
.pill-live { color: var(--green); }
.pill-sleep { color: var(--violet); }
.pill-wait { color: var(--muted); }
.follow-off { position: absolute; right: 12px; top: 12px; }
.follow-off[hidden], .loading[hidden] { display: none; }
.hud-btn {
  min-height: 44px; padding: 10px 14px; color: var(--text); background: rgba(10, 12, 40, 0.78);
  border: 1px solid var(--line); backdrop-filter: blur(6px); transition: border-color 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}
.hud-btn:hover { filter: none; border-color: var(--cyan); background: rgba(20, 26, 70, 0.9); }
.hud-btn:active { transform: translateY(1px); }
.hud-btn:disabled { opacity: 0.5; cursor: default; border-color: var(--line); }
.hud-btn[aria-pressed="true"], .hud-btn[aria-expanded="true"] { border-color: var(--cyan); color: var(--cyan); }
.hud-actions { position: absolute; right: 12px; bottom: 12px; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; max-width: calc(100% - 24px); }
.mix {
  position: absolute; right: 12px; bottom: 66px; display: grid; gap: 10px; width: min(240px, calc(100% - 24px));
  padding: 12px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; backdrop-filter: blur(6px);
  opacity: 0; transform: translateY(6px); visibility: hidden; pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s linear 0.18s;
}
.mix.open { opacity: 1; transform: none; visibility: visible; pointer-events: auto; transition-delay: 0s; }
.mix label { display: grid; grid-template-columns: 64px minmax(0, 1fr); align-items: center; gap: 8px; font-size: 14px; }
.mix input { width: 100%; min-height: 32px; accent-color: var(--cyan); }
.loading { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); padding: 8px 14px; border-radius: 99px; background: var(--panel); color: var(--muted); font-size: 14px; pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .hud-btn, .mix { transition: none; } }
.fallback { position: absolute; inset: auto 12px 12px 12px; padding: 10px; background: var(--panel); border-radius: 10px; }

.side { display: flex; flex-direction: column; gap: 12px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.panel h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); margin: 0 0 8px; }
.panel.grow { flex: 1; }
.leaderboard, .agents, .feed { list-style: none; margin: 0; padding: 0; }
.leaderboard { counter-reset: rank; }
.leaderboard li, .agents li { display: flex; justify-content: space-between; gap: 8px; padding: 4px 0; font-size: 14px; }
.leaderboard li:not(.muted)::before { counter-increment: rank; content: counter(rank); color: var(--gold); font-family: Orbitron, sans-serif; width: 18px; }
.leaderboard .name, .agents .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agents button { all: unset; cursor: pointer; display: flex; gap: 8px; align-items: center; flex: 1; min-width: 0; }
.agents button:hover .name, .agents button:focus-visible .name { color: var(--cyan); }
.agents button:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; border-radius: 4px; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; box-shadow: 0 0 8px currentColor; }
.stat { color: var(--muted); font-size: 12px; white-space: nowrap; }
.feed { max-height: 280px; overflow-y: auto; font-size: 13px; }
.feed li { padding: 4px 0; border-bottom: 1px solid rgba(120, 140, 255, 0.08); overflow-wrap: anywhere; }
.feed .k-say { color: #cfe8ff; }
.feed .k-hit { color: #ffc2ea; }
.feed .k-defeat { color: var(--gold); }
.feed .k-join, .feed .k-respawn { color: var(--green); }
.feed .k-forge { color: var(--cyan); }
.feed .k-restyle { color: var(--violet); }
.feed .k-fizzle { color: var(--muted); }
.muted { color: var(--muted); }

button {
  font: 600 14px Inter, sans-serif; color: #05061a; background: linear-gradient(90deg, var(--cyan), #7ab8ff);
  border: 0; border-radius: 10px; padding: 10px 16px; cursor: pointer;
}
button:hover { filter: brightness(1.1); }
button:focus-visible, input:focus-visible { outline: 2px solid var(--pink); outline-offset: 2px; }

.join { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; margin: 40px 0; padding: 22px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
@media (min-width: 900px) { .join { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.join > * { min-width: 0; }
.join h2 { margin: 0 0 8px; }
.join p { color: var(--muted); }
.signup label { display: block; font-weight: 600; margin-bottom: 6px; }
.signup-row { display: flex; gap: 8px; flex-wrap: wrap; }
.signup input { flex: 1; min-width: 0; font: 16px Inter, sans-serif; color: var(--text); background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.signup small { color: var(--muted); }
.error { color: var(--red) !important; }
.key-box { background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.key-box .warn { color: var(--gold); margin-top: 0; }
.code-row { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 10px; }
.code-row code { flex: 1; min-width: 0; overflow-wrap: anywhere; font: 13px ui-monospace, Menlo, monospace; background: #03040f; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; color: #cfe8ff; }
.code-row button { padding: 8px 12px; }

.how { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; margin-bottom: 40px; }
@media (min-width: 800px) { .how { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.how article { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.how h3 { margin: 0 0 8px; font-size: 16px; color: var(--cyan); }
.how p { margin: 0; color: var(--muted); }

.foot { max-width: 1280px; margin: 0 auto; padding: 20px 16px 40px; color: var(--muted); font-size: 13px; }
