* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  background: #0a0a14;
  font-family: 'Inter', sans-serif;
  overflow: hidden;
  color: #e2e8f0;
  user-select: none;
}
canvas { display: block; width: 100vw; height: 100vh; position: fixed; top: 0; left: 0; z-index: 0; }
.glass {
  background: rgba(255,255,255,0.05);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
#joinScreen {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  background: rgba(10,10,20,0.85);
  backdrop-filter: blur(8px);
}
.join-box {
  padding: 40px 48px;
  width: 380px;
  max-width: 90%;
  text-align: center;
}
.join-box h1 {
  font-size: 48px;
  font-weight: 700;
  margin-bottom: 4px;
  background: linear-gradient(135deg, #4f8cf7, #a855f7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.join-box .subtitle {
  color: #94a3b8;
  margin-bottom: 24px;
  font-weight: 400;
}
.join-box input[type="text"] {
  width: 100%;
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.05);
  color: #fff;
  font-size: 16px;
  margin-bottom: 16px;
  transition: border 0.2s;
}
.join-box input[type="text"]:focus {
  outline: none;
  border-color: #4f8cf7;
}
.color-picker {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 20px;
  color: #cbd5e1;
}
.color-picker input[type="color"] {
  width: 40px;
  height: 40px;
  border: 2px solid rgba(255,255,255,0.2);
  border-radius: 50%;
  cursor: pointer;
  background: transparent;
  padding: 0;
}
#joinBtn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #4f8cf7, #a855f7);
  color: #fff;
  font-weight: 700;
  font-size: 18px;
  cursor: pointer;
  transition: transform 0.1s;
}
#joinBtn:hover { transform: scale(1.02); }
.credits { margin-top: 20px; font-size: 12px; color: #475569; }

#topBar {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 8px 24px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  flex-wrap: wrap;
  justify-content: center;
}
#topBar .stat {
  display: flex;
  align-items: center;
  gap: 4px;
  color: #e2e8f0;
}
#bossHealthBar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 120px;
}
#bossHealthText { color: #fca5a5; font-size: 13px; }
#bossHealthFill {
  width: 60px;
  height: 6px;
  background: #dc2626;
  border-radius: 4px;
  transition: width 0.2s;
}
#leaderboard {
  position: fixed;
  top: 80px;
  right: 16px;
  z-index: 10;
  width: 200px;
  padding: 16px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}
.lb-title {
  font-weight: 700;
  font-size: 16px;
  color: #4f8cf7;
  margin-bottom: 12px;
  text-align: center;
}
#lbEntries {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.lb-entry {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(255,255,255,0.03);
}
.lb-entry .lb-color { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.lb-entry .lb-name { flex: 1; color: #e2e8f0; }
.lb-entry .lb-score { color: #94a3b8; font-weight: 600; }

#chatContainer {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 10;
  width: 300px;
  max-width: 90%;
}
#chatMessages {
  max-height: 120px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 12px;
  margin-bottom: 4px;
  background: rgba(0,0,0,0.3);
  backdrop-filter: blur(4px);
  border-radius: 12px;
  font-size: 13px;
}
.chat-msg {
  display: flex;
  gap: 6px;
  align-items: baseline;
}
.chat-name { font-weight: 600; }
.chat-text { color: #e2e8f0; word-break: break-word; }
#chatInput {
  width: 100%;
  padding: 8px 14px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 20px;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  color: #fff;
  font-size: 14px;
  outline: none;
}
#chatInput:focus { border-color: #4f8cf7; }
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #475569; border-radius: 4px; }

@media (max-width: 640px) {
  #topBar { font-size: 12px; gap: 12px; padding: 6px 16px; }
  #leaderboard { width: 160px; right: 8px; top: 72px; padding: 12px; }
  #chatContainer { width: 200px; bottom: 12px; left: 12px; }
  .join-box { padding: 24px; }
}
#shopBtn {
  background: #4f8cf7;
  border: none;
  color: white;
  padding: 4px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
}
#shopBtn:hover { background: #3a7bd5; }

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 50;
  background: rgba(20,20,40,0.9);
  backdrop-filter: blur(12px);
  padding: 24px 32px;
  border-radius: 16px;
  min-width: 280px;
  max-width: 90%;
  border: 1px solid rgba(255,255,255,0.1);
}
.modal-content h2 {
  color: #4f8cf7;
  text-align: center;
  margin-bottom: 20px;
}
.shop-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  color: #e2e8f0;
}
.shop-item .cost { color: #fbbf24; }
.buy-btn {
  background: #4f8cf7;
  border: none;
  color: #fff;
  padding: 4px 12px;
  border-radius: 6px;
  cursor: pointer;
}
.buy-btn:hover { background: #3a7bd5; }
#closeShopBtn {
  display: block;
  margin: 16px auto 0;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.2);
  color: #94a3b8;
  padding: 6px 20px;
  border-radius: 8px;
  cursor: pointer;
}
#closeShopBtn:hover { background: rgba(255,255,255,0.05); }
