:root {
  --bg: #0a0612;
  --panel: rgba(20, 14, 32, 0.92);
  --panel-border: #ff4ecd44;
  --text: #f0e8ff;
  --muted: #a89cc4;
  --accent: #ff4ecd;
  --accent2: #4ec5ff;
  --err: #ff5c6c;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

#app, #game {
  position: fixed;
  inset: 0;
  width: 100%; height: 100%;
}

#game canvas { display: block; }

.hidden { display: none !important; }

.overlay {
  position: fixed; inset: 0;
  background: radial-gradient(ellipse at center, #1a0a2a 0%, #050308 100%);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
  padding: 16px;
}

.panel {
  width: 100%; max-width: 360px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 24px 20px;
  box-shadow: 0 0 40px #ff4ecd33, 0 0 80px #4ec5ff22;
  text-align: center;
}

.panel h1 {
  margin: 0 0 4px;
  font-size: 26px;
  letter-spacing: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.panel h3 {
  margin: 0 0 12px;
  font-size: 18px;
  color: var(--accent);
}

.hint { color: var(--muted); font-size: 13px; margin: 0 0 16px; }
.hint.small { font-size: 12px; margin-top: 12px; }

input {
  width: 100%;
  background: #1a1228;
  border: 1px solid #ffffff22;
  color: var(--text);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 15px;
  margin: 6px 0;
  outline: none;
}
input:focus { border-color: var(--accent); }

button {
  background: #2a1f3f;
  color: var(--text);
  border: 1px solid #ffffff22;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 15px;
  cursor: pointer;
}
button.primary {
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border: none;
  color: #fff;
  font-weight: 600;
  width: 100%;
  margin-top: 12px;
}
button:active { transform: translateY(1px); }

.row { display: flex; gap: 8px; margin-top: 10px; }
.row > button { flex: 1; }

.avatar-picker {
  display: flex; gap: 8px; justify-content: center;
  flex-wrap: wrap;
  margin: 12px 0;
}
.av {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--c, #888);
  border: 2px solid transparent;
  color: #000; font-weight: 700;
  padding: 0;
}
.av.selected { border-color: #fff; box-shadow: 0 0 12px var(--c); }

.err { color: var(--err); font-size: 13px; min-height: 18px; margin-top: 6px; }

/* HUD */
#hud {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  pointer-events: none;
  padding: 8px;
}
#chat-log {
  pointer-events: auto;
  max-height: 30vh;
  overflow-y: auto;
  padding: 8px 10px;
  font-size: 13px;
  line-height: 1.5;
  background: linear-gradient(transparent, rgba(0,0,0,0.55));
  -webkit-mask-image: linear-gradient(transparent, #000 30%);
          mask-image: linear-gradient(transparent, #000 30%);
}
#chat-log .line { margin: 2px 0; }
#chat-log .line .who { color: var(--accent2); margin-right: 4px; }
#chat-log .sys { color: var(--muted); font-style: italic; }

#chat-input-row {
  pointer-events: auto;
  display: flex; gap: 6px;
  padding: 6px;
  background: rgba(10, 6, 18, 0.85);
  border-top: 1px solid #ffffff11;
}
#chat-input-row input {
  flex: 1;
  margin: 0;
  font-size: 14px;
  padding: 8px 10px;
}
#chat-input-row button { padding: 8px 12px; font-size: 14px; }

/* DJ panel z-index above game but allow chat above? keep simple */
#dj-panel { z-index: 40; }

@media (max-height: 500px) {
  #chat-log { max-height: 22vh; }
}
