:root {
  --ink: #f6f5f1;
  --mute: #8b8680;
  --bg: #0a0a0a;
  --paper: #131211;
  --hair: #2a2724;
  --target: #ff5a3c;
  --racing: #38d8a7;
  --escape: #c084fc;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; background: var(--bg); color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

body.hub {
  background:
    radial-gradient(1200px 600px at 20% -10%, #1a1916 0%, transparent 60%),
    radial-gradient(900px 600px at 110% 110%, #20100c 0%, transparent 55%),
    var(--bg);
}

.bar {
  display: flex; align-items: center; gap: 14px;
  padding: 18px clamp(16px, 4vw, 32px);
  border-bottom: 1px solid var(--hair);
}
.brand {
  font-family: "Iowan Old Style", Georgia, serif;
  font-size: clamp(20px, 4vw, 28px);
  letter-spacing: -0.02em;
}
.brand span { color: var(--mute); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--target); box-shadow: 0 0 12px var(--target); }
.meta {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px; color: var(--mute); letter-spacing: 0.06em; text-transform: uppercase;
}

.grid {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  padding: clamp(20px, 5vw, 40px);
  max-width: 1200px; margin: 0 auto;
}

.card {
  display: block; text-decoration: none; color: var(--ink);
  background: var(--paper); border: 1px solid var(--hair); border-radius: 18px;
  padding: 28px; position: relative; overflow: hidden;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
  min-height: 240px;
}
.card:hover { transform: translateY(-2px); }
.card .num {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px; letter-spacing: 0.14em; color: var(--mute);
}
.card h2 {
  font-family: "Iowan Old Style", Georgia, serif;
  font-size: clamp(28px, 4vw, 38px); margin: 10px 0 12px; letter-spacing: -0.02em;
}
.card p { color: var(--mute); font-size: 15px; line-height: 1.55; margin: 0 0 26px; }
.card .cta {
  display: inline-block; padding: 8px 16px; border-radius: 999px;
  border: 1px solid var(--hair); font-size: 13px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 0.06em;
}
.card::after {
  content: ""; position: absolute; right: -40px; bottom: -40px;
  width: 180px; height: 180px; border-radius: 50%; opacity: .22;
  filter: blur(20px);
}
.card.target { border-color: rgba(255,90,60,.25); }
.card.target::after { background: var(--target); }
.card.target:hover { border-color: var(--target); box-shadow: 0 8px 30px rgba(255,90,60,.15); }
.card.target .cta { color: var(--target); border-color: rgba(255,90,60,.35); }

.card.racing { border-color: rgba(56,216,167,.25); }
.card.racing::after { background: var(--racing); }
.card.racing:hover { border-color: var(--racing); box-shadow: 0 8px 30px rgba(56,216,167,.15); }
.card.racing .cta { color: var(--racing); border-color: rgba(56,216,167,.35); }

.card.escape { border-color: rgba(192,132,252,.25); }
.card.escape::after { background: var(--escape); }
.card.escape:hover { border-color: var(--escape); box-shadow: 0 8px 30px rgba(192,132,252,.15); }
.card.escape .cta { color: var(--escape); border-color: rgba(192,132,252,.35); }

.foot {
  padding: 24px clamp(16px, 4vw, 32px) 40px;
  font-size: 13px; color: var(--mute);
  border-top: 1px solid var(--hair);
  text-align: center;
}

/* in-scene back-to-hub button overlay (for VR pages) */
.hud-back {
  position: fixed; top: 14px; left: 14px; z-index: 9999;
  padding: 8px 14px; border-radius: 999px;
  background: rgba(10,10,10,0.65); color: var(--ink);
  border: 1px solid var(--hair); text-decoration: none;
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px;
  backdrop-filter: blur(8px);
}
.hud-tag {
  position: fixed; top: 14px; right: 14px; z-index: 9999;
  padding: 8px 14px; border-radius: 999px;
  background: rgba(10,10,10,0.55); color: var(--mute);
  border: 1px solid var(--hair);
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 11px;
  letter-spacing: 0.06em;
  backdrop-filter: blur(8px);
}
.room-body { background: #0a0e2a; }
.brand-link { text-decoration: none; color: inherit; }

/* ====== JOIN OVERLAY ====== */
#join-overlay {
  position: fixed; inset: 0; z-index: 10000;
  background: radial-gradient(800px 500px at 50% 30%, #1b2455 0%, #07060b 70%), #07060b;
  display: grid; place-items: center;
  transition: opacity .4s ease;
}
#join-overlay.hidden { opacity: 0; pointer-events: none; }
.join-card {
  width: min(420px, 92vw);
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 20px;
  padding: 32px 28px;
  color: #f6f5f1;
  backdrop-filter: blur(12px);
  box-shadow: 0 24px 80px rgba(0,0,0,0.6);
}
.join-card h1 {
  margin: 0 0 8px; font-family: "Iowan Old Style", Georgia, serif;
  font-size: 28px; letter-spacing: -0.02em;
}
.join-card p { margin: 0 0 24px; color: #8b8680; font-size: 14px; }
.join-card label { display: block; font-size: 12px; color: #8b8680; margin-bottom: 6px; font-family: ui-monospace, monospace; letter-spacing: 0.06em; text-transform: uppercase; }
.join-card label.row { display: flex; gap: 8px; align-items: center; text-transform: none; letter-spacing: 0; color: #c8c4bc; margin: 16px 0; }
.join-card input[type=text] {
  width: 100%; padding: 12px 14px; border-radius: 10px;
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12);
  color: #f6f5f1; font-size: 16px; outline: none;
  margin-bottom: 4px;
}
.join-card input[type=text]:focus { border-color: #5b9fff; }
.join-card button {
  margin-top: 8px; width: 100%; padding: 12px 18px; border-radius: 10px;
  background: #5b9fff; border: 0; color: #061528; font-weight: 700; font-size: 15px; cursor: pointer;
  transition: transform .12s;
}
.join-card button:hover { transform: translateY(-1px); }
.join-card small { display: block; margin-top: 18px; color: #6b6760; font-size: 12px; line-height: 1.5; }

/* ====== CHAT ====== */
#chat-panel {
  position: fixed; right: 14px; bottom: 14px; z-index: 9999;
  width: min(320px, 90vw); height: 360px;
  background: rgba(8,8,16,0.78); color: #f6f5f1;
  border: 1px solid rgba(255,255,255,0.12); border-radius: 14px;
  backdrop-filter: blur(10px);
  display: flex; flex-direction: column;
  transition: transform .25s ease, opacity .25s ease;
}
#chat-panel.closed { transform: translateY(120%); opacity: 0; pointer-events: none; }
.chat-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; border-bottom: 1px solid rgba(255,255,255,0.08);
  font-family: ui-monospace, monospace; font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: #8b8680;
}
.chat-head button {
  background: transparent; border: 0; color: #8b8680; font-size: 18px; cursor: pointer;
}
#chat-log {
  flex: 1; overflow-y: auto; padding: 10px 14px; font-size: 13px; line-height: 1.45;
}
#chat-log .msg { margin-bottom: 6px; }
#chat-log .msg .who { color: #5b9fff; margin-right: 6px; font-weight: 600; }
#chat-log .msg.system { color: #6b6760; font-style: italic; }
#chat-log .msg.system .who { display: none; }
#chat-form { padding: 10px 12px; border-top: 1px solid rgba(255,255,255,0.08); }
#chat-form input {
  width: 100%; padding: 9px 12px; border-radius: 8px;
  background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.08);
  color: #f6f5f1; font-size: 14px; outline: none;
}
#chat-form input:focus { border-color: #5b9fff; }
#chat-open {
  position: fixed; right: 14px; bottom: 14px; z-index: 9998;
  width: 52px; height: 52px; border-radius: 50%;
  background: rgba(8,8,16,0.78); color: #f6f5f1; border: 1px solid rgba(255,255,255,0.12);
  font-size: 22px; cursor: pointer; backdrop-filter: blur(10px);
}
#chat-open.pulse { animation: pulse 1.4s ease-in-out 2; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(91,159,255,0.6);} 50% { box-shadow: 0 0 0 14px rgba(91,159,255,0);} }

#net-badge {
  position: fixed; top: 50px; right: 14px; z-index: 9999;
  padding: 6px 12px; border-radius: 999px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 11px;
  letter-spacing: 0.05em; backdrop-filter: blur(8px);
}
#net-badge.net-off { background: rgba(30,20,20,0.6); color: #8b8680; border: 1px solid rgba(255,255,255,0.08); }
#net-badge.net-pending { background: rgba(60,50,20,0.6); color: #ffd166; border: 1px solid rgba(255,209,102,0.3); }
#net-badge.net-on { background: rgba(20,40,30,0.7); color: #38d8a7; border: 1px solid rgba(56,216,167,0.4); }
